码迷,mamicode.com
首页 > 编程语言 > 详细

Not registered via @EnableConfigurationProperties or marked as Spring component

时间:2020-06-25 21:51:24      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:图片   nal   ring   enable   blog   问题   ati   来源   时报   

一、问题来源

  学习Spring Boot 时,利用@ConfigurationProperties(prefix = "")来绑定属性时报错

二、报错信息

Not registered via @EnableConfigurationProperties or marked as Spring component

技术图片

 

三、解决过程

  用可爱的百度一搜,小白们也碰到一样的问题,回答也不少,

  https://blog.csdn.net/qq_42635345/article/details/85761314比如这位仁兄。

  我解决的时候在@ConfigurationProperties注解下,添加了@EnableConfigurationProperties就OK了,至于在pom.xml中配置

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-configuration-processor</artifactId>
	<optional>true</optional>
</dependency>  

  依赖来解决此问题,应该是不对题的,这段代码的作用是配置文件处理器,解决最开始粉色背景部分(Spring Boot Configuration Annotation Processor not found in classpath)的问题。所以我将这段代码注释后,并没有报错。如下图所示。

技术图片

技术图片

 四、总结

  SpringBoot中,将类中的属性和配置文件中的配置进行绑定时出现的问题

 

Not registered via @EnableConfigurationProperties or marked as Spring component

标签:图片   nal   ring   enable   blog   问题   ati   来源   时报   

原文地址:https://www.cnblogs.com/peanut-zh/p/13192766.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!