文档介绍:
<?xml version="" encoding="UTF-8"?>
<beans xmlns="ema/beans"
xmlns:xsi="1/XMLSchema-instance"
xmlns:aop="ema/aop"
xmlns:tx="ema/tx"
xsi:schemaLocation="
ema/beans ema/beans/spring-beans-
ema/tx ema/tx/spring-tx-
ema/aop ema/aop/spring-aop-">
<bean id="entityManagerFactory"
class="">
<property name="persistenceUnitName" value="testjpaPU" />
<property name="jpaVendorAdapter">
<bean
class="">
<property name="showSql" value="true"></property>
<property name="generateDdl" value="true"></property>
</bean>
</property>
</bean>
<bean id="transactionManager"
class="">
<property name="entityManagerFactory"
ref="entityManagerFactory" />
</bean>
<aop:config>
<aop:pointcut id="crudMethos"
expression_r="execution(* .*.*(..))" />
<!-- 第一个*号代表可以是任意返回类型,第二个*代表包下的所有类,第三个*代表类下的所有方法,之后的(..)代表任意的参数-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="crudMethos" />
</aop:config>
<tx:annotation-driven transaction-manager="transactionManager" />
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="edit*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<bean id="studentDao" class="">
<property name="entityManagerFactory">
<ref bean="entityManagerFactory" />
</property>
</bean>
<bean id="studentService"
class="">
<property name="dao">
<ref bean="studentDao" />
</property>
</bean>
</beans>
Ja