java - Spring : XML Configuration Location -


i learner of spring have build test project spring ioc container , have configure beans.xml in project root path , load application , bean it.

spring.xml in project root directory

beanfactory bean = new xmlbeanfactory(new filesystemresource("spring.xml")); 

spring.xml in source file

beanfactory bean = new xmlbeanfactory(new filesystemresource("src/spring.xml")); 

this code load beans.xml file

applicationcontext context = new genericxmlapplicationcontext("beans.xml"); 

my question is there standards or conventions creation of xml file name , location of file in real project.because in reading articles found there might multiple xml files large project service.xml , dao.xml.

it can useful have bean definitions span multiple xml files. each individual xml configuration file represents logical layer such defining dao beans etc. in architecture should place xml configuration files under src/resources , access them

new classpathxmlapplicationcontext(new string[] {"services.xml", "daos.xml"}); 

from spring's manual:

you can use application context constructor load bean definitions these xml fragments. constructor takes multiple resource locations, shown in previous section. alternatively, use 1 or more occurrences of element load bean definitions file or files. example:

<beans>   <import resource="services.xml"/>   <import resource="resources/messagesource.xml"/>   <import resource="/resources/themesource.xml"/>  </beans> 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -