<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"XMLNS:AOP= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"Xmlns:context= "Http://www.springframework.org/schema/context"Xmlns:tx= "Http://www.springframework.org/schema/tx"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd Http://www.sprin GFRAMEWORK.ORG/SCHEMA/AOP http://www.springframework.org/schema/aop/spring-aop.xsd/HTTP Www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd "> <!--Data Source Configuration - <BeanID= "DataSource"class= "Com.mchange.v2.c3p0.ComboPooledDataSource"><!--Note that ID is fixed, otherwise it will be an error - < Propertyname= "Driverclass"value= "Oracle.jdbc.driver.OracleDriver"></ Property> < Propertyname= "Jdbcurl"value= "JDBC:ORACLE:THIN:@127.0.0.1:1521:ORCL"></ Property> < Propertyname= "User"value= "Gao"></ Property> < Propertyname= "Password"value= "1"></ Property> < Propertyname= "Initialpoolsize"value= "3"></ Property> < Propertyname= "Maxpoolsize"value= "Ten"></ Property> < Propertyname= "Maxstatements"value= "+"></ Property> < Propertyname= "Acquireincrement"value= "2"></ Property> </Bean> <!--JdbcTemplate Tool class instances - <BeanID= "JdbcTemplate"class= "Org.springframework.jdbc.core.JdbcTemplate"> < Propertyname= "DataSource"ref= "DataSource"></ Property> </Bean> <Context:component-scanBase-package= "Cn.test.anno"></Context:component-scan> <!--################# #配置事务 ########################### - <BeanID= "Txmanager"class= "Org.springframework.jdbc.datasource.DataSourceTransactionManager"> < Propertyname= "DataSource"ref= "DataSource"></ Property> </Bean> <Tx:annotation-drivenTransaction-manager= "Txmanager"/></Beans>
PackageCn.test.anno;ImportJavax.annotation.Resource;Importorg.springframework.stereotype.Component;Importorg.springframework.transaction.annotation.Isolation;Importorg.springframework.transaction.annotation.Propagation;Importorg.springframework.transaction.annotation.Transactional;/*** Logic Control layer *@authorGAOZC **/@Component Public classDeptservice {@ResourcePrivateDeptdao Deptdao; @Transactional Public voidSave (Dept Dept) {deptdao.save (Dept); inti=1/0; Deptdao.save (dept); }}
Spring Oracle Annotations