Skip to content

This java annotation processor scans for spring annotations that mark a class as injectable and generates a spring configuration class containing imports for all classes marked this way

License

Notifications You must be signed in to change notification settings

eitco/spring-config-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Build status Maven Central Version

spring-config-generator

This java annotation processor scans for spring annotations that mark a class as a stereotype and generates a spring configuration class containing imports for all classes marked this way.

It is integrated by adding the module as a dependency to a project:

<dependency>
    <groupId>de.eitco.cicd</groupId>
    <artifactId>spring-config-generator</artifactId>
    <version>4.0.2</version>
    <optional>true</optional>
</dependency> 

The following annotations are recognized:

  • @Component
  • @Service
  • @Repository
  • @Controller
  • @RestController
  • @ControllerAdvice
  • @RestControllerAdvice
  • @Configuration
  • @Endpoint

The annotation processor will generate a java file that defines a spring configuration that imports all classes processed that are annotated with one of these annotations. The code of the generated class will roughly look like this:

package <your package name>;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import javax.annotation.processing.Generated;

@Generated("de.eitco.commons.build.essentials.config.generator.SpringConfigGenerationProcessor")
@Configuration
@Import({
        <list of annotated classes>
	})
public class <your class name> {}

The target package can be configured using the annotation processor parameter generated.spring.config.package which defaults to de.eitco. The class name can be configured using the annotation processor parameter generated.spring.config.class defaulting to ComponentConfiguration.

The integration tests pose a simple example.

About

This java annotation processor scans for spring annotations that mark a class as injectable and generates a spring configuration class containing imports for all classes marked this way

Resources

License

Stars

Watchers

Forks

Packages

No packages published