解決springboot configuration processor對(duì)maven子模塊不起作用的問題
環(huán)境
idea 2021.1
maven 3.6.1
springboot 2.3.10.RELEASED
問題:
spring boot configuration annotation processor not configured

單模塊maven項(xiàng)目
在pom內(nèi)添加以下依賴即可消除警告
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
多模塊且喊子模塊maven項(xiàng)目
在父module的pom內(nèi)添加以下依賴
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<!-- <optional>true</optional> 不注釋掉子模塊無(wú)法引用到此依賴 -->
</dependency>
然后在maven-compiler-plugin內(nèi)的annotationProcessorPaths中添加相應(yīng)path
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<target>${maven.compiler.target}</target>
<source>${maven.compiler.source}</source>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring-boot.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
這樣就能消除警告啦,至于自定義yml或properties的內(nèi)容快捷提示且能跳轉(zhuǎn)相應(yīng)配置類,可以看如下簡(jiǎn)單demo
demo
application.yml
my:
a:
name: lisi
age: 11
person:
age: 12
name: zhangsan
MyConfig.java
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* <p>
* demo
* </p>
*
* @author wandoupeas
* @date 2021-09-16 11:48 上午
*/
@Data
@Component
@ConfigurationProperties(prefix = "my.a")
public class MyConfig {
private String name;
private String age;
private MyConfigName person;
}
MyConfigName.java
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* <p>
* demo
* </p>
*
* @author wandoupeas
* @date 2021-09-16 11:48 上午
*/
@Data
@Component
@ConfigurationProperties(prefix = "my.a.person")
public class MyConfigName {
private String name = "zhangsan";
private String age = "123";
}
到此這篇關(guān)于解決springboot configuration processor對(duì)maven子模塊不起作用的問題的文章就介紹到這了,更多相關(guān)spring boot maven子模塊不起作用內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Spring Boot企業(yè)常用的starter示例詳解
這篇文章主要給大家介紹了關(guān)于Spring Boot企業(yè)常用starter的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Spring Boot具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12
使用JPA自定義VO接收返回結(jié)果集(unwrap)
這篇文章主要介紹了使用JPA自定義VO接收返回結(jié)果集(unwrap),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-11-11
SpringBoot中YAML語(yǔ)法及幾個(gè)注意點(diǎn)說明
這篇文章主要介紹了SpringBoot中YAML語(yǔ)法及幾個(gè)注意點(diǎn)說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-02-02
java實(shí)現(xiàn)文件導(dǎo)入導(dǎo)出
這篇文章主要介紹了java實(shí)現(xiàn)文件導(dǎo)入導(dǎo)出的方法和具體示例代碼,非常的簡(jiǎn)單實(shí)用,有需要的小伙伴可以參考下2016-04-04
java開發(fā)之MD5加密算法的實(shí)現(xiàn)
本篇文章介紹了,java開發(fā)之MD5加密算法的實(shí)現(xiàn)。需要的朋友參考下2013-05-05
Spring框架通過工廠創(chuàng)建Bean的三種方式實(shí)現(xiàn)
這篇文章主要介紹了Spring框架通過工廠創(chuàng)建Bean的三種方式實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03
SpringBoot實(shí)現(xiàn)登錄校驗(yàn)(JWT令牌)
JWT全稱為JSON Web Token,是一種用于身份驗(yàn)證的開放標(biāo)準(zhǔn),本文主要介紹了SpringBoot實(shí)現(xiàn)登錄校驗(yàn)(JWT令牌),具有一定的參考價(jià)值,感興趣的可以了解一下2023-12-12
詳解使用Spring快速創(chuàng)建web應(yīng)用的兩種方式
這篇文章主要介紹了詳解使用Spring快速創(chuàng)建web應(yīng)用的兩種方式,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11

