@ConfigurationProperties(prefix=”author”) 没有指定classpath时,IDEA提示没有找到classpath。
在浏览器中访问的结果是null 0是由于在没指定路劲的情况下,默认在resource下的applications.properties中查找,如果找到则返回值,如果没有找到则返回默认值null/0/false…
分析
- 出现spring boot Configuration Annotation Proessor not found in classpath的提示是在用了@ConfigurationProperties这个注解时,所以问题出现在ConfigurationProperties注解。
- 根据提示的not found in classpath,查询此注解的使用关于怎么指定classpath,进而查询location,spring boot1.5以上版本@ConfigurationProperties取消location注解
- 解决方案:
在配置类中采用@Component的方式注册为组件,然后使用@PropertySource来指定自定义的资源目录.(本人测试用@Serv