环境
idea 2021.1
maven 3.6.1
springboot 2.3.10.RELEASED
问题:
spring boot configuration annotation processor not configured
单模块maven项目
在pom
内添加以下依赖即可消除警告
1
2
3
4
5
|
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional> true </optional>
</dependency>
|
多模块且喊子模块maven项目
在父module的pom
内添加以下依赖
1
2
3
4
5
|
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<!-- <optional> true </optional> 不注释掉子模块无法引用到此依赖 -->
</dependency>
|
然后在maven-compiler-plugin
内的annotationProcessorPaths
中添加相应path
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<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的内容快捷提示且能跳转相应配置类,可以看如下简单demo
demo
application.yml
1
2
3
4
5
6
7
|
my:
a:
name: lisi
age: 11
person:
age: 12
name: zhangsan
|
MyConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
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" ;
}
|
到此这篇关于解决springboot configuration processor对maven子模块不起作用的问题的文章就介绍到这了,更多相关spring boot maven子模块不起作用内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://www.cnblogs.com/wandoupeas/p/spring-boot-configuration-processor-not-configured.html