不论是用@Configuration还是@Component都报错

来源:5-1 SpringBoot 资源文件属性配置

CWForward4109215

2019-07-30 17:06

类:

@Component

@ConfigurationProperties(prefix = "com.example.opensource")

@PropertySource(value = "classpath:resource.properties")

public class Resource {

private String name;

private String website;

private String language;

错误描述

Description:


Field resource in com.example.controller.HelloController required a bean of type 'com.example.pojo.Resource' that could not be found.


The injection point has the following annotations:

- @org.springframework.beans.factory.annotation.Autowired(required=true)



Action:


Consider defining a bean of type 'com.example.pojo.Resource' in your configuration.


写回答 关注

1回答

  • CWForward4109215
    2019-07-30 17:43:00

    这个问题是因为启动类 要放到最外边  https://img.mukewang.com/5d40111c0001129403040175.jpg

SpringBoot开发常用技术整合

SpringBoot 极简开发的框架整合利器

102171 学习 · 508 问题

查看课程

相似问题