However, some Spring modules, such as the security module, still require plain XML configuration. Some applications may refer to old legacy code which has not been converted to Java configuration too.
In this case, one needs to mix Spring XML and Java configuration. This can be achieved with the @ImportResource Spring annotation:
@Configuration @ImportResource({"classpath:/WEB-INF/spring-security.xml", "classpath:/WEB-INF/legacy-config.xml"}) public class Config { @Bean MyBean MyBean() { return new MyBean(); } }
More Spring related posts here.
I was trying this, but I can't do that, can you publish an example?
ReplyDeleteThere is an example available here: http://technotes.tostaky.biz/2012/09/spring-security-and-annotation-example.html Cheers!
Delete