Not registered via @EnableConfigurationProperties, | A component required a bean of type ‘xxx‘

Not registered via @EnableConfigurationProperties, marked as Spring component
当使用@ConfigurationProperties时报这个错误
在这里插入图片描述
解决办法:
一、在pom.xml中添加依赖:

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

二、在你对应的类中添加@Component注解
在这里插入图片描述
这样就没有问题了,如果你没有解决把这个提示改成Warning的话就会在运行时报这个错

Description:
A component required a bean of type ‘com.czxy.changgou4.config.JwtProperties’ that could not be found.
Action:
Consider defining a bean of type ‘com.czxy.changgou4.config.JwtProperties’ in your configuration.

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_48143996/article/details/122196007