Configuration Annotation Proessor not found in classpath
- 使用 @ConfigurationProperties 报错
- spring boot1.5 以上版本@ConfigurationProperties 取消 location 注解,只能使用 @PropertySource
- 但使用 @PropertySource 依然出现报错
官方解决方案,Maven 引入依赖
1
2
3
4
5
| <dependency>
<groupId> org.springframework.boot </groupId>
<artifactId> spring-boot-configuration-processor </artifactId>
<optional> true </optional>
</dependency>
|
参考:https://blog.csdn.net/w05980598/article/details/79167826
java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘xxx’ method
1
2
3
4
5
6
7
| at com.xxx.springbootconfiguration.SpringbootConfigurationApplication.main
(SpringbootConfigurationApplication.java:10) [classes/:na]
Caused by: java.lang.IllegalStateException: Ambiguous mapping.
Cannot map 'configurationController' method
com.xxx.springbootconfiguration.controller.configurationController#getUser()
to {GET }: There is already 'configurationController' bean method
com.xxx.springbootconfiguration.controller.configurationController#getInfo() mapped.
|
原因:
controller 层 @GetMapping 重复使用了两个相同的路径
1
2
3
4
5
6
7
8
9
| @GetMapping
public void getInfo() {
...
}
@GetMapping
public void getUser() {
...
}
|
两个 @GetMapping 都没有指定路径,才会有这样一条报错(已经被 getInfo map 了)
1
2
| to {GET }: There is already 'configurationController' bean method
com.xxx.springbootconfiguration.controller.configurationController#getInfo() mapped.
|
解决方法:
为 @GetMapping 添加值,保险一点两个都加,只加一个也可以
1
2
3
4
5
6
7
8
9
| @GetMapping("/info")
public void getInfo() {
...
}
@GetMapping("/user")
public void getUser() {
...
}
|