简体   繁体   English

Maven 需要为托管依赖项 spring-boot-configuration-processor 指定插件版本

[英]Maven requires plugin version to be specified for the managed dependency spring-boot-configuration-processor

I have a maven project with modules.我有一个带有模块的 maven 项目。 The parent for my root project is spring-boot-starter-parent , which provides a lot of dependency management.我的根项目的父级是spring-boot-starter-parent ,它提供了很多依赖管理。

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 ).在我的模块中,我使用spring-boot-configuration-processor ,它是spring-boot-starter-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 .虽然spring-boot-dependencies对于各种依赖的版本有很多属性,但是对于spring-boot-configuration-processor的版本没有属性。 Nor does it include spring-boot-configuration-processor in plugin management.它也不在插件管理中包含spring-boot-configuration-processor

How do I use the inherited version of this plugin instead of having to explicitly specify the version myself?如何使用此插件的继承版本,而不必自己明确指定版本?

You need to inherit from parent POM:您需要从父 POM 继承:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>{YOUR_VERSION}</version>
</parent>

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.我确实相信,而不是配置maven-compiler-plugin ,您只需将spring-boot-configuration-processor声明为具有scope=provided的项目的依赖项 - maven-compiler-pluginannotationProcessorPathsannotationProcessors参数的目的不是添加注释处理器,但强制编译器仅使用定义的注释处理器。

<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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 spring-boot-configuration-processor依赖仅适用于IDE支持吗? - Is spring-boot-configuration-processor dependency only for IDE support? 什么是spring-boot-configuration-processor? 人们为什么要从中排除图书馆? 为什么它在依赖树中不可见? - What is the spring-boot-configuration-processor ? Why do people exclude libraries from it? Why is it invisible in dependency tree? 根据建议添加了spring-boot-configuration-processor,但在RoundDispatcher中产生了NoClassDefFoundError - Added spring-boot-configuration-processor as recommended, but produced NoClassDefFoundError in RoundDispatcher 如何在Spring Boot Starters中指定maven版本? - How is the maven version specified in Spring Boot Starters? Spring启动maven插件,具有依赖的主类 - Spring boot maven plugin with a main class in a dependency Maven 依赖与较旧的 Spring Boot 版本 - Maven dependency with older spring boot version 版本2.1.7的Maven配置问题-Spring Boot - Maven Configuration Problem with Version 2.1.7 - Spring Boot Spring Boot:无法识别 Maven 依赖项中的实体:“不是托管类型” - Spring Boot: Entities within a Maven dependency not recognized: "Not a managed type" 使用 spring-boot-maven-plugin 从依赖 jar 拆分版本号? - Spliting version number from dependency jar using spring-boot-maven-plugin? 行家! Spring Boot 采用了依赖项目中提到的错误依赖版本 - MAVEN! Spring Boot takes wrong dependency version mentioned in dependency project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM