Split a applicationcontext.xml (you can also separate the action section and the TX transaction section)
1. DAO part
<!--Configure DAO - <BeanID= "EmployeeDAO"class= "Cn.bdqn.jboa.dao.hibimpl.EmployeeDaoHibImpl"> < Propertyname= "Sessionfactory"ref= "Sessionfactory" /> </Bean> <BeanID= "Claimvoucherdao"class= "Cn.bdqn.jboa.dao.hibimpl.ClaimVoucherDaoHibImpl"> < Propertyname= "Sessionfactory"ref= "Sessionfactory" /> </Bean> <BeanID= "Claimvoucherdetaildao"class= "Cn.bdqn.jboa.dao.hibimpl.ClaimVoucherDetailDaoHibImpl"> < Propertyname= "Sessionfactory"ref= "Sessionfactory" /> </Bean>
2. Service part
<!--Configure the business tier - <BeanID= "EmployeeService"class= "Cn.bdqn.jboa.service.impl.EmployeeServiceImpl"> < Propertyname= "EmployeeDAO"ref= "EmployeeDAO"></ Property> </Bean> <BeanID= "Claimvoucherservice"class= "Cn.bdqn.jboa.service.impl.ClaimVoucherServiceImpl"> < Propertyname= "Claimvoucherdao"ref= "Claimvoucherdao" /> < Propertyname= "Claimvoucherdetaildao"ref= "Claimvoucherdetaildao" /> </Bean>
3. Basic class
<!--inject multiple profiles with <import resource= "Xxx.xml" > Mode - <!--<import resource= "Applicationcontext-dao.xml"/> <import resource= "Applicationcontext-service.xml"/&G T - <!--defining DBCP Data Sources - <BeanID= "DataSource"class= "Org.apache.commons.dbcp.BasicDataSource"> <!--specifying the JDBC driver class - < Propertyname= "Driverclassname"value= "Oracle.jdbc.driver.OracleDriver"> </ Property> <!--provide the URL address of the connection database - < Propertyname= "url"value= "Jdbc:oracle:thin: @localhost: 1521:orcl"> </ Property> <!--provide the user name and password to connect to the database - < Propertyname= "username"value= "BDQN"></ Property> < Propertyname= "Password"value= "BDQN"></ Property> </Bean> <!--Defining sessionfactory Beans - <BeanID= "Sessionfactory"class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!--inject a well-defined data source for Localsessionfactorybean - < Propertyname= "DataSource"> <refBean= "DataSource" /> </ Property> <!--Add Hibernate configuration Parameters - < Propertyname= "Hibernateproperties"> <Props> <propKey= "Hibernate.dialect">Org.hibernate.dialect.OracleDialect</prop> <propKey= "Hibernate.show_sql">True</prop> <propKey= "Hibernate.format_sql">True</prop> </Props> </ Property> <!--To add an object-relational mapping file - <!--<property name= "mappingresources" > <list> <value>cn/bdqn/jboa/entity/clai Mvoucher.hbm.xml</value> <value>cn/bdqn/jboa/entity/ClaimVoucherDetail.hbm.xml</value> <value>cn/bdqn/jboa/entity/Employee.hbm.xml</value> <value>cn/bdqn/jboa/enti Ty/checkresult.hbm.xml</value> <value>cn/bdqn/jboa/entity/Position.hbm.xml</value> <value>cn/bdqn/jboa/entity/Department.hbm.xml</value> <value>cn/bdqn/jboa/entity /dictionary.hbm.xml</value> </list> </property> - < Propertyname= "Mappingdirectorylocations"> <List> <value>classpath:cn/bdqn/jboa/entity/</value> </List> </ Property> </Bean> <!--defining the transaction manager - <BeanID= "Txmanager"class= "Org.springframework.orm.hibernate3.HibernateTransactionManager"> < Propertyname= "Sessionfactory"ref= "Sessionfactory" /> </Bean> <Tx:adviceID= "Txadvice"Transaction-manager= "Txmanager"> <tx:attributes> <Tx:methodname= "find*"read-only= "true" /> <Tx:methodname= "search*"read-only= "true" /> <Tx:methodname= "query*"read-only= "true" /> <Tx:methodname= "add*"Propagation= "REQUIRED" /> <Tx:methodname= "del*"Propagation= "REQUIRED" /> <Tx:methodname= "update*"Propagation= "REQUIRED" /> <Tx:methodname= "do*"Propagation= "REQUIRED" /> <Tx:methodname="*"Propagation= "REQUIRED"read-only= "true" /> </tx:attributes> </Tx:advice> <Aop:config> <!--Defining Pointcuts - <Aop:pointcutID= "Servicemethod"expression= "Execution (* cn.bdqn.jboa.service.*.* (..))" /> <!--combine transaction notifications with Pointcuts - <Aop:advisorAdvice-ref= "Txadvice"Pointcut-ref= "Servicemethod" /> </Aop:config> <!--control layer (class in ID struts.xml) Each of the following beans must be incremented scope= "prototype" Property - <!--<bean id= "useraction" class= "Cn.bdqn.jboa.action.UserAction" scope= "prototype" > <property nam E= "EmployeeService" ref= "EmployeeService" ></property> </bean> -
Splitting the spring configuration file