Java -- Spring configuration, tracing Pring
<? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: context = "http://www.springframework.org/schema/context" xmlns: tx = "http://www.springframework.org/schema/tx" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context Http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd "default-autowire =" byName "default-lazy-init =" true "> <! -- Default-autowire = "byName" is automatically assembled based on the property name. default-lazy-init = "true" spring configuration defaults to default-lazy-init to false, if it is set to true, sping does not load the entire object instance graph, which greatly reduces the initialization time and spring startup speed.
This is only to save the startup time during the development process. In the deployment to the actual environment, it is not necessary to set default-lazy-init to true. After all, deployment to the actual environment is not a frequent issue. It is not a big problem to start every 1 minute, and it can improve server Efficiency --> <! -- Configure the data source --> <bean id = "dataSource" class = "org. springframework. jdbc. datasource. driverManagerDataSource "> <property name =" driverClassName "> <value> com. mysql. jdbc. driver </value> </property> <property name = "url"> <value> jdbc: mysql: // localhost/ssh? CharacterEncoding = UTF-8 </value> </property> <property name = "username"> <value> root </value> </property> <property name = "password"> <value> 123 </value> </property> </bean> <! -- Configure SessionFactory --> <bean id = "sessionFactory" class = "org. springframework. orm. hibernate3.LocalSessionFactoryBean "> <property name =" dataSource "> <ref bean =" dataSource "/> </property> <property name =" mappingResources "> <list> <value> com/ ssh/pojo/User. hbm. xml </value> </list> </property> <property name = "hibernateProperties"> <props> <prop key = "hibernate. show_ SQL "> true </prop> </props> </property> </be An> <! -- HibernateTemplate --> <bean id = "hibernateTemplate" class = "org. springframework. orm. hibernate3.HibernateTemplate "> <property name =" sessionFactory "> <ref bean =" sessionFactory "/> </property> </bean> <! -- Configure the data persistence layer --> <bean id = "userDao" class = "com. ssh. dao. impl. userDaoImpl "> <property name =" hibernateTemplate "ref =" hibernateTemplate "> </property> </bean> <! -- Configure the business logic layer --> <bean id = "userService" class = "com. ssh. service. impl. userServiceImpl "> <property name =" userDao "ref =" userDao "> </property> </bean> <! -- Configure control layer --> <bean id = "UserAction" class = "com. ssh. action. userAction "scope =" prototype "> <property name =" userService "ref =" userService "> </property> </bean> <! -- Configure pojo --> <bean id = "User" class = "com. ssh. pojo. User" scope = "prototype"/> <! -- Transaction Management --> <bean id = "transactionManager" class = "org. springframework. orm. hibernate3.HibernateTransactionManager "> <property name =" sessionFactory "> <ref bean =" sessionFactory "/> </property> </bean> </beans>