Git Product home page Git Product logo

spring-configuration-validation-processor's Introduction

spring-configuration-validation-processor Build Status

This project provides a Java 6 Annotation processor that emits compiler warnings and errors in case one of the following conditions is encountered in a Spring @Configuration class:

  • @Configuration classes must not be final.
  • @Configuration classes must have a visible no-arg constructor.
  • @Configuration class constructors must not be @Autowired.
  • Nested @Configuration classes must be static.
  • @Bean methods must not be private.
  • @Bean methods must not be final.
  • @Bean methods must have a non-void return type.
  • @Bean methods should be declared in classes annotated with @Configuration.
  • @Bean methods returning a BeanFactoryPostProcessor should be static.
  • Only @Bean methods returning a BeanFactoryPostProcessor should be static.

##Quick Start

Maven

  1. Add the following dependency to your Maven POM:
<dependencies>
    <dependency>
      <groupId>com.github.pellaton.config-validation-processor</groupId>
  	    <artifactId>config-validation-processor</artifactId>
  	    <version>3.0.7</version>
    </dependency>
</dependencies>
  1. Configure the maven-compiler-plugin to run the annotation processor:
<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.2</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <encoding>UTF-8</encoding>
            <annotationProcessors>
              <annotationProcessor>com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessorJava8</annotationProcessor>
              <!-- For Java 7: <annotationProcessor>com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessorJava7</annotationProcessor> -->
              <!-- For Java 6: <annotationProcessor>com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessorJava6</annotationProcessor> -->
            </annotationProcessors>
          </configuration>
        </plugin>
    </plugins>
</build>

Gradle

Add the following to your gradle file:

configurations {
    annotationProcessor
}

task configureAnnotationProcessing(type: JavaCompile, group: 'build', description: 'Processes the @Configuration classes') {
  source = sourceSets.main.java
  classpath = configurations.compile + configurations.annotationProcessor
  options.compilerArgs = [
          "-proc:only",
          "-processor", "com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessorJava8"
  ]
  destinationDir = buildDir
}

compileJava {
    dependsOn configureAnnotationProcessing
}

dependencies {
    annotationProcessor 'com.github.pellaton.config-validation-processor:config-validation-processor-java8:3.0.7'
}

Eclipse

  1. Enable annotation processing and annotation processing in editor in the Eclipse project properties (Java Compiler > Annotation Processing) Screenshot
  2. Configure the path to the processor's jar file (Java Compiler > Annotation Processing > Factory Path) Screenshot

IntelliJ IDEA (Maven Project)

In IntelliJ IDEA, the annotation processor works out if the box in Maven projects configuring the processor in the compiler plugin configuration. Unfortunately, this does not work for Gradle projects :-/

IntelliJ IDEA (Non Maven Project)

  1. Add the jar file containing the annotation processor to the module libraries
  2. Enable annotation processing in the global IntelliJ IDEAD compiler settings
  3. Add the fully qualified class name of the processor to the annotation processors list Screenshot

Netbeans (Maven Project)

In Netbeans, the annotation processor works out if the box in Maven projects configuring the processor in the compiler plugin configuration.

Netbeans (Non Maven Project)

  1. Add the jar file containing the annotation processor to the project libraries
  2. Enable annotation processing and annotation processing in editor in the project properties
  3. Add the fully qualified class name of the processor to the annotation processors list Screenshot

Perform a release

$ mvn release:prepare release:perform -Darguments=-Dgpg.passphrase=SECRET

spring-configuration-validation-processor's People

Contributors

ferstl avatar marschall avatar pellaton avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.