分享

@configurationProperties注解时 idea弹出 Spring Boot Annotion processor not found in classpath

 小样样样样样样 2020-06-04

 

@ConfigurationProperties(prefix="") 没有指定 classpath 时,IDEA 提示没有找到 classpath。

原因:

1--》在没指定路劲的情况下,默认在 resource 下的 applications.properties (yml) 中查找,

如果找到则返回值,如果没有找到则返回默认值null/0/false…所以不用管它也是

可以正常运行的, 有时候无法注释数据为null

2--》加入依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
之后如果ConfigurationProperties继续报错:Not registered via @EnableConfigurationProterties or marked as……
解决办法:加上@Component注解

 

可以关闭 IDEA 的提示:

setting 下搜索 spring,找到 springBoot 取消勾选 show notification panel

controller的使用

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多