Spring Full profile with annotations (auto sweep package)

Source: Internet
Author: User
Tags aop rollback

<?xml version= "1.0" encoding= "UTF-8"?>
<beans
Default-autowire= "ByName"
Default-lazy-init= "true"
Xmlns= "Http://www.springframework.org/schema/beans"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
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:context= "Http://www.springframework.org/schema/context"
Xsi:schemalocation= "
Http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
Http://www.springframework.org/schema/aop
Http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
Http://www.springframework.org/schema/tx
Http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
Http://www.springframework.org/schema/context
Http://www.springframework.org/schema/context/spring-context-3.0.xsd
">

<!--open annotation configuration-->
<context:annotation-config/>

<!--component scanning of the specified package-->
<context:component-scan base-package= "Com.lun"/>

<!--linked database-->
<bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" >
<property name= "Driverclassname" value= "Oracle.jdbc.driver.OracleDriver" ></property>
<property name= "url" value= "JDBC:ORACLE:THIN:@127.0.0.1:1521:ORCL" ></property>
<property name= "username" value= "LUN" ></property>
<property name= "password" value= "123" ></property>
</bean>

<!--configuration of hibernate sessionfactory-->
<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name= "DataSource" ref= "DataSource" ></property>
<property name= "Hibernateproperties" >
<props>
<!--database dialect-->
<prop key= "Hibernate.dialect" >org.hibernate.dialect.Oracle9Dialect</prop>
<!--The SQL statements that are executed in the console print-->
<prop key= "Hibernate.show_sql" >true</prop>
</props>
</property>
<!--load all the entity profiles-->
<property name= "Mappingdirectorylocations" >
<list>
<value>classpath:com/lun/entity</value>
</list>
</property>
</bean>

<!--transaction processor-->
<bean id= "TransactionManager" class= "Org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name= "Sessionfactory" ref= "Sessionfactory"/>
</bean>

<!--transaction notification configuration-->
<tx:advice id= "Txadvice" transaction-manager= "TransactionManager" >
<tx:attributes>
<tx:method name= "get*" read-only= "true" propagation= "not_supported"/>
<tx:method name= "find*" read-only= "true" propagation= "not_supported"/>
<tx:method name= "select*" read-only= "true" propagation= "not_supported"/>
<tx:method name= "save*" rollback-for= "Exception" propagation= "REQUIRED"/>
<tx:method name= "add*" rollback-for= "Exception" propagation= "REQUIRED"/>
<tx:method name= "update*" rollback-for= "Exception" propagation= "REQUIRED"/>
<tx:method name= "del*" rollback-for= "Exception" propagation= "REQUIRED"/>
<tx:method name= "*" rollback-for= "Exception" propagation= "REQUIRED"/>
</tx:attributes>
</tx:advice>

<!--transaction Slice configuration-->
<aop:config>
<aop:pointcut expression= "Execution (* com.lun.biz.*.* (..))" id= "Transactionpointcut"/>
<aop:advisor advice-ref= "Txadvice" pointcut-ref= "Transactionpointcut"/>
</aop:config>

<!--injected JdbcTemplate-->
<bean id= "JdbcTemplate" class= "Org.springframework.jdbc.core.JdbcTemplate" >
<constructor-arg ref= "DataSource"/>
</bean>

<!--injected Hibernatetemplate-->
<bean id= "Hibernatetemplate" class= "Org.springframework.orm.hibernate3.HibernateTemplate" >
<property name= "Sessionfactory" ref= "Sessionfactory"/>
</bean>
</beans>

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.