I have the following class
public class ConnectionPool {
@Autowired
private Properties props;
@Autowired
private Key internalKey;
public ConnectionPool{
System.out.println(internalKey);
System.out.println(props);
}
}
I am creating the ConnectionPool class as a bean in the following way in a class called ApplicationConfig.
@Bean
ConnectionPool returnConnectionPool(){
ConnectionPool cPool = new ConnectionPool();
return cPool;
}
In the ApplicationConfig class I also have
@Bean
Properties returnAppProperties()
{
Properties props = new Properties();
return props;
}
@Bean
Key returnInternalKey()
{
Key key = new Key();
return key;
}
Why does
System.out.println(internalKey);
System.out.println(props);
print null when the Spring mvc app is starting? I thought Spring took care of all the bean instantiation and injection? What else do I have to do?