Project Name: 1ma1ma
Jdbc.xml
<bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" destroy-method= " Close "&NBSP;
p:driverclassname=" ${jdbc.driverclassname} "
p:url= "${jdbc.url}"
p:username= "${ Jdbc.username} "
p:password=" ${jdbc.password} "
p:maxactive= "${jdbc.pool-size}"
&NBSP;P: minevictableidletimemillis= "600000" p:timebetweenevictionrunsmillis= "900000"
p:removeabandoned= "true" p:logabandoned= "true" p:removeabandonedtimeout= "+"
p:maxwait=
/>
<bean id= "TransactionManager" class= "Org.springframework.jdbc.datasource.DataSourceTransactionManager" >
<property name= "DataSource" >
<ref local= "DataSource"/>
</property>
</bean>
<tx:annotation-driven transaction-manager= "TransactionManager"/>
<context:component-scan base-package= "Com.yaoma.*" >
<context:exclude-filter type= "Annotation" expression= "Org.springframework.stereotype.Controller"/>
</context:component-scan>
Servlet-context.xml
<context:component-scan base-package= "Com.yaoma.*" >
<context:include-filter type= "Annotation" expression= "Org.springframework.stereotype.Controller"/>
<context:exclude-filter type= "Annotation" expression= "Org.springframework.stereotype.Service"/>
</context:component-scan>
@Transactional
public int Delete (string imgroupid, String userid) throws Exception {
Update the corresponding groups table content according to Imgroupid and UserID
int is_return = groups_dao.isdeleted_groups (imgroupid, userid, 0);
if (Is_return = = 0) {
throw new RuntimeException ("Is_return is 0;");
}
Delete the corresponding data on the ring letter
String Hx_return = Hx_service.delete_group (imgroupid);
if (Hx_return = = null) {
throw new RuntimeException ("Hx_return is null");
}
Return Integer.parseint (Hx_return);
}
@Transactional Note Labels
Because you are running, you use RuntimeException to throw exceptions, and you cannot use try to catch exceptions in a class, directly throws exception throws an exception
Rollback is invalid if the runtime throws an exception using exception
Spring MVC annotation method uses transaction rollback