I have a maven project with modules. The parent for my root project is spring-boot-starter-parent
, which provides a lot of dependency management.
In my module, I use spring-boot-configuration-processor
, which is one of the dependencies managed by spring-boot-starter-parent
(well, actually managed by its parent, spring-boot-dependencies
).
If I don't specify the version in the plugins section, my build fails with:
Resolution of annotationProcessorPath dependencies failed: For artifact {org.springframework.boot:spring-boot-configuration-processor:null:jar}: The version cannot be empty. -> [Help 1]
So, I am forced to have the plugins section look like this:
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>2.6.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
However, I would prefer to reference the inherited version. Although spring-boot-dependencies
has a lot of properties for the versions of various dependencies, it does not have a property for the version of spring-boot-configuration-processor
. Nor does it include spring-boot-configuration-processor
in plugin management.
How do I use the inherited version of this plugin instead of having to explicitly specify the version myself?
CodePudding user response:
You need to inherit from parent POM:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>{YOUR_VERSION}</version>
</parent>
CodePudding user response:
I do believe instead of configuring maven-compiler-plugin
you just need to declare spring-boot-configuration-processor
as a dependency of your project with scope=provided
- the purpose of annotationProcessorPaths
and annotationProcessors
parameters of maven-compiler-plugin
is not to add annotation processor, but to force the compiler to use defined annotation processors only.
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
...
</plugins>
<dependencies>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<scope>provided</scope>
</dependency>
...
</dependencies>