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

單模塊maven項目
在pom內(nèi)添加以下依賴即可消除警告
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
多模塊且喊子模塊maven項目
在父module的pom內(nèi)添加以下依賴
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<!-- <optional>true</optional> 不注釋掉子模塊無法引用到此依賴 -->
</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)配置類,可以看如下簡單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對maven子模塊不起作用的問題的文章就介紹到這了,更多相關(guān)spring boot maven子模塊不起作用內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Spring Boot企業(yè)常用的starter示例詳解
這篇文章主要給大家介紹了關(guān)于Spring Boot企業(yè)常用starter的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Spring Boot具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12
使用JPA自定義VO接收返回結(jié)果集(unwrap)
這篇文章主要介紹了使用JPA自定義VO接收返回結(jié)果集(unwrap),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-11-11
Spring框架通過工廠創(chuàng)建Bean的三種方式實現(xiàn)
這篇文章主要介紹了Spring框架通過工廠創(chuàng)建Bean的三種方式實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03
詳解使用Spring快速創(chuàng)建web應(yīng)用的兩種方式
這篇文章主要介紹了詳解使用Spring快速創(chuàng)建web應(yīng)用的兩種方式,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11

