12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?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:tx="http://www.springframework.org/schema/tx"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd">
-
- <!-- 配置jdbc -->
- <context:property-placeholder location="classpath:/properties/db.properties"/>
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="${jdbc.driver}" />
- <property name="url" value="${jdbc.url}" />
- <property name="username" value="${jdbc.username}" />
- <property name="password" value="${jdbc.password}" />
- </bean>
-
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <property name="mapperLocations" value="classpath:/mapping/*.xml" />
- </bean>
-
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.demo.aop.dao" />
- <property name="sqlSessionFactory" ref="sqlSessionFactory" />
- </bean>
-
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource" />
- </bean>
-
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="*"/>
- <tx:method name="find*" read-only="true"/>
- </tx:attributes>
- </tx:advice>
-
- <aop:config>
- <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.yuan.ehcache.service.impl.*.*(..))"/>
- </aop:config>
-
- <bean id="controllerAop" class="com.demo.aop.ControllerAOP" />
-
- <aop:config>
- <aop:aspect id="myAop" ref="controllerAop">
- <aop:pointcut id="target"
- expression="execution(* com.demo.controller.*.*(..))" />
- <aop:around method="handlerControllerMethod" pointcut-ref="target" />
- </aop:aspect>
- </aop:config>
- </beans>
|