为了账号安全,请及时绑定邮箱和手机立即绑定

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

类:

@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 回答

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

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

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

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信