1
我有下面的类春天创建bean依赖于其他豆类
public class ConnectionPool {
@Autowired
private Properties props;
@Autowired
private Key internalKey;
public ConnectionPool{
System.out.println(internalKey);
System.out.println(props);
}
}
我创建的连接池类是在一个名为ApplicationConfig类以下方式豆。
@Bean
ConnectionPool returnConnectionPool(){
ConnectionPool cPool = new ConnectionPool();
return cPool;
}
在ApplicationConfig级我也有
@Bean
Properties returnAppProperties()
{
Properties props = new Properties();
return props;
}
@Bean
Key returnInternalKey()
{
Key key = new Key();
return key;
}
为什么
System.out.println(internalKey);
System.out.println(props);
打印空当的Spring MVC应用程序正在启动?我以为春天照顾了所有的bean实例化和注入?我还有什么要做的?
是的它是'@Configuration public class ApplicationConfig { – user3809938