自定义starter的时候遇到的问题,网上看到有说没什么问题,idea debug级别调低就行,但试了不好使。
这里功能是希望能读取配置application.properties 的配置参数,并自动装配bean
package com.fengyu.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "hello")
public class HelloProperties {
private String name;
private String address;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
public String toString() {
return "HelloProperties{" +
"name='" + name + '\'' +
", address='" + address + '\'' +
'}';
}
}
但这里的AutoConfiguration就是取不到HelloProperties(已经在同一个文件夹下了)。
用其他项目调用这个starter,把装配这个bean 这段去掉是好使的,看来问题还是在 Could not autowire 这里
最后加这个注解就可以了:
@ComponentScan("com.fengyu")