网上看来的一种写法
某个配置类,构造函数的时候去查数据库取数据,
configMapper这里IDEAL报以下错误:
Could not autowire. No beans of 'ConfigMapper' type found.
但是,代码也能正常运行也查到东西了,就是不知道有什么隐患没?
...
@Configuration
@Data
public class AppConfig {
private String some;
//configMapper这里ideal是报错的
@Autowired
public AppConfig(ConfigMapper configMapper) {
System.out.println("---------------");
List<ConfigDO> all= configMapper.selectList();
System.out.println(all);
this.some = ...;
}
}