Beans. xml, springbeans. xml
1 <? Xml version = "1.0" encoding = "UTF-8"?> 2 <beans xmlns = "http://www.springframework.org/schema/beans" 3 xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" 4 xmlns: context = "http://www.springframework.org/schema/context" 5 xmlns: aop = "http://www.springframework.org/schema/aop" 6 xmlns: tx = "http://www.springframework.org/schema/tx" 7 xsi: schemaLocation = "http://www.springframework.org/schema/beans /Spring-beans-2.5.xsd 8 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd 9 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd10 http://www.springframework.org/schema/aop11 http://www.springframework.org/schema/aop/spring-aop.xsd "> 12 <! -- Open annotation injection --> 13 <context: annotation-config/> 14 <context: component-scan base-package = "com. hkwy"/> 15 <! -- Added support for AOP annotation --> 16 <aop: aspectj-autoproxy/> 17 <! -- Configure the data source --> 18 <bean id = "dataSource" class = "org. apache. commons. dbcp. BasicDataSource"> 19 <! -- Basic Parameter --> 20 <property name = "driverClassName" value = "com. mysql. jdbc. driver "> </property> 21 <property name =" url "value =" jdbc: mysql: // localhost: 3306/spring1 "> </property> 22 <property name =" username "value =" root "> </property> 23 <property name =" password "value =" root"> </property> 24 <! -- Configure the connection pool parameters --> 25 <property name = "initialSize" value = "1"> </property> 26 <! -- Maximum number of connection pools --> 27 <property name = "maxActive" value = "500"> </property> 28 <! -- Reduce the number of connections to the minimum value when idle --> 29 <property name = "maxIdle" value = "2"> </property> 30 <! -- Minimum value of the connection pool when idle --> 31 <property name = "minIdle" value = "1"> </property> 32 <! -- Maximum wait time --> 33 <property name = "maxWait" value = "1000"> </property> 34 </bean> 35 <! -- Configure the hibernate SessionFactory annotation Method --> 36 <bean id = "sessionFactory" class = "org. springframework. orm. hibernate3.annotation. AnnotationSessionFactoryBean"> 37 <! -- Configure the data source --> 38 <property name = "dataSource" ref = "dataSource"> </property> 39 <! -- Specifies the object class. You only need to specify the package --> 40 <property name = "packagesToScan"> 41 <value> com. hkwy. entity </value> 42 </property> 43 <! -- Configure other hibernate parameters --> 44 <property name = "hibernateProperties"> 45 <props> 46 <prop key = "hibernate. dialect "> org. hibernate. dialect. mySQLDialect </prop> 47 <prop key = "hibernate. show_ SQL "> true </prop> 48 <prop key =" hibernate. format_ SQL "> true </prop> 49 <prop key =" hibernate. hbm2ddl. auto "> update </prop> 50 </props> 51 </property> 52 </bean> 53 <! -- Submit hibernate to Spring to manage its transactions --> 54 <! -- Configure the Transaction Manager --> 55 <bean id = "txmanager" class = "org. springframework. orm. hibernate3.HibernateTransactionManager "> 56 <property name =" sessionFactory "ref =" sessionFactory "> </property> 57 </bean> 58 <! -- Configure Spring AOP to manage transactions --> 59 <aop: config> 60 <! -- Configure the dao to be managed --> 61 <aop: pointcut expression = "execution (* com. hkwy. dao. *. *(..)) "id =" aoph "/> 62 <! -- Use advisor to determine the specific method to add transaction control --> 63 <aop: advisor advice-ref = "txadvice" pointcut-ref = "aoph"/> 64 </aop: config> 65 <! -- Configure advice to determine which data operations need to be added to transaction control --> 66 <tx: advice id = "txadvice" transaction-manager = "txmanager"> 67 <tx: attributes> 68 <tx: method name = "*" propagation = "REQUIRED"/> 69 </tx: attributes> 70 </tx: advice> 71 72 </beans>