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