问题1:项目提示Spring Boot Configuration Annotation Proessor not found in classpath。
问题2:在Spring Boot项目中使用注解@ConfigurationProperties时,注解报错,
提示Not registered via @EnableConfigurationProperties or marked as Spring component。
解决方案:
问题1:在pom.xml中添加依赖:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency>
此时项目不再提示Spring Boot Configuration Annotation Proessor not found in classpath。
问题2:在需要使用这个类的地方,加上@EnableConfigurationProperties,此时这个类中的@ConfigurationProperties注解就不再报错。例如本类为DruidDataSourceProperties,我需要在DruidConfig类中去使用这个类,那么就在DruidConfig类上方加上@EnableConfigurationProperties(DruidDataSourceProperties.class)即可。