java - Spring Boot load beans from context xml in library -
i have 2 applications:
application
child
: it's spring app xml schema-based configuration. haveapplicationcontext.xml
.application
parent
: spring boot app. uses applicationchild
library.
is possible load beans defined in child
xml, , put them parent
context?
yes possible.
from javadoc:
as mentioned above, @configuration classes may declared regular spring definitions within spring xml files. it possible import spring xml configuration files @configuration classes using @importresource annotation. bean definitions imported xml can injected using @autowired or @import.
here example same javadoc mix beans loaded xml in beans defined in configuration class:
@configuration @importresource("classpath:/com/acme/database-config.xml") public class appconfig { @inject datasource datasource; // xml @bean public mybean mybean() { // inject xml-defined datasource bean return new mybean(this.datasource); } }
Comments
Post a Comment