Springboot项目 手写util类 使用@Value注解读取不到yml中配置的值

@Component 
@ConfigurationProperties(prefix = "aa")
@Getter
@Setter
public class Utils {

private String username;
private String password;


private static Utils A_UTILS=new Utils ();

@Autowired
public void init(FtpUtils utils){
    Utils.A_UTILS=utils;
    }
}

注入bean

yml 文件里

aa.username=zhangshan
aa.password=123456

注入成功了

原文地址:https://www.cnblogs.com/xiqoqu/p/13684657.html