Tags

links:
http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/beans.html#beans-java-instantiating-container
http://stackoverflow.com/questions/10534893/how-to-override-an-imported-resource-using-spring-configuration

summary:
– Both @Import @ImportResource work with @Configuration
– @Import should really be @ImportConfiguration in my opinion cuz it’s for importing another @Configuration’ed class
– @ImportResource is used when we have a class/java-centric config instead of xml-centric config but would use some minor xml cfg with javaconfig
– @ImportResource ie. XML “always” takes precedence over @Bean (annotation). This make sense for using external config to change logic rather than editing your code to do so.
– @PropertySource is to inject properties file into our context

examples:

@Configuration
@Import(AnotherConfig.class)
@ImportResource(“classpath:/com/acme/properties-config.xml”)
@PropertySource(“classpath:some.properties”)
public class AppConfig
{
blah…
}

Advertisements