@RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration(value = "src/main/webapp") @ContextHierarchy({ @ContextConfiguration(name = "parent", locations = "classpath:./spring/applicationContext.xml") }) public class Messa…
项目名:1ma1ma jdbc.xml <bean  id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"             p:driverClassName="${jdbc.driverClassName}"            p:url="${jdbc.url}"  …
使用静态变量   private static String iPSetCode=null;…
背景:在面试时候问到事务方法在调用过程中出现异常,是否会传递的问题,平时接触的比较少,有些懵逼. spring异常抛出触发事务回滚策略 Spring.EJB的声明式事务默认情况下都是在抛出unchecked exception后才会触发事务的回滚 测试用业务逻辑方法: /** * 如果在spring事务配置中不为切入点(如这里的切入点可以定义成test*)配置事务在什么情况下回滚(格式:-引起回滚的异常类型) * 则spring默认只会在service方法抛出unchecked exceptio…
Spring.EJB的声明式事务默认情况下都是在抛出unchecked exception后才会触发事务的回滚 /** * 如果在spring事务配置中不为切入点(如这里的切入点可以定义成test*)配置事务在什么情况下回滚(格式:-引起回滚的异常类型) * 则spring默认只会在service方法抛出unchecked exception才会触发回滚 */ public class TestServiceImpl extends Service implements TestService …
转:http://hi.baidu.com/iduany/item/20f8f8ed24e1dec5bbf37df7 Spring AOP声明式事务异常回滚 近日测试用例,发现这样一个现象:在业务代码中,有如下两种情况,比如:throw new RuntimeException("xxxxxxxxxxxx"); 事物回滚throw new Exception("xxxxxxxxxxxx"); 事物没有回滚 自以为很了解事物,或许时间久远的缘故,没分析出来何故,遂查阅…
近日测试用例,发现这样一个现象:在业务代码中,有如下两种情况,比如:throw new RuntimeException("xxxxxxxxxxxx"); 事物回滚throw new Exception("xxxxxxxxxxxx"); 事物没有回滚 自以为很了解事物,或许时间久远的缘故,没分析出来何故,遂查阅了下资料,写下了如下的内容,供参考: 1).Spring的AOP即声明式事务管理默认是针对unchecked exception回滚.也就是默认对Runtim…
spring mvc在Controller中获取ApplicationContext web.xml中进行正常的beans.xml和spring-mvc.xml的配置: 需要在beans.xml中进行需要加载的类的配置:不能在spring-mvc.xml中配置: beans.xml中的配置: <bean id="deployMode" class="java.lang.String"> <constructor-arg> <value&…
Spring MVC 使用tomcat中配置的数据源 配置tomcat数据源 打开tomcat目录下的conf目录,编辑sever.xml目录.在<GlobalNamingResources>标签中添加数据源配置: <Resource name="jdbc/dbsourse" scope="Shareable" type="javax.sql.DataSource" factory="org.apache.tomcat…
Spring MVC 了解WebApplicationContext中特殊的bean类型 Spring的DispatcherServlet使用了特殊的bean来处理请求.渲染视图等,这些特定的bean是Spring MVC框架的一部分.如果你想指定使用哪个特定的bean,你可以在web应用上下文WebApplicationContext中简单地配置它们.当然这只是可选的,Spring MVC维护了一个默认的bean列表,如果你没有进行特别的配置,框架将会使用默认的bean.下一小节会介绍更多的细…