[SpringBoot] Not registered via @EnableConfigurationPropertise or marked as Spring component

发布时间 2023-07-31 11:08:03作者: 伶俐虫虫

问题描述

在Springboot进行参数绑定时,出现

解决

添加以下依赖

        <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-configuration-processor</artifactId>
			<optional>true</optional>
		</dependency>
  • 当编写yml,properties配置文件,会有提示
    但会出现以下错误

    需要注解@Component,讲该组件添加到容器中,才能使用容器提供的@ConfigurationProperties