Configuration series: (Things Management) simple configuration of Applicationcontext-transaction.xml in SSM

Source: Internet
Author: User

<?xml version= "1.0" encoding= "UTF-8"?>

<beans xmlns= "Http://www.springframework.org/schema/beans"

xmlns:context= "Http://www.springframework.org/schema/context" xmlns:p= "http://www.springframework.org/schema/p"

xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP" xmlns:tx= "Http://www.springframework.org/schema/tx"

Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"

xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-4.0.xsd

Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd

HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP http://www.springframework.org/schema/aop/spring-aop-4.0.xsd/HTTP Www.springframework.org/schema/tx

Http://www.springframework.org/schema/tx/spring-tx-4.0.xsd

Http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd ">

<!--define transaction manager--

<bean id= "TransactionManager"

class= "Org.springframework.jdbc.datasource.DataSourceTransactionManager" >

<property name= "DataSource" ref= "DataSource"/>

</bean>


<!--define transaction policies--

<tx:advice id= "Txadvice" transaction-manager= "TransactionManager" >

<tx:attributes>

<!--all methods that start with query are read-only

<tx:method name= "query*" read-only= "true"/>

<!--other methods to use the default transaction policy--

<tx:method name= "*"/>

</tx:attributes>

</tx:advice>


<aop:config>

<!--pointcut element defines a pointcut in which the first asterisk in the execution matches the return type of the method.

Here the asterisk indicates that all return types are matched. Com.simple.sso.service.*.* (..) Indicates that all of the classes that match the Com.simple.sso.service package

Method-

<aop:pointcut id= "mypointcut" expression= "Execution (* com.simple.sso.service.*.* (..))"/>

<!--apply a defined transaction-handling policy to the above pointcut--

<aop:advisor advice-ref= "Txadvice" pointcut-ref= "Mypointcut"/>

</aop:config>

</beans>


Configuration series: (Things Management) simple configuration of Applicationcontext-transaction.xml in SSM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.