文章分类 -  Spring

摘要:Spring事务配置的五种方式 前段时间对Spring的事务配置做了比较深入的研究,在此之间对Spring的事务配置虽说也配置过,但是一直没有一个清楚的认识。通过这次的学习发觉Spring的事务配置只要把思路理清,还是比较好掌握的。 总结如下: Spring配置文件中关于事务配置总是由三个组成部分, 阅读全文
posted @ 2016-07-04 21:55 乱世_独自美 阅读(101) 评论(0) 推荐(0)
摘要:前提:spring的xml已配置了<bean id="",class=""></bean> 1)通过类的变量 2)构造函数 阅读全文
posted @ 2016-07-04 11:08 乱世_独自美 阅读(78) 评论(0) 推荐(0)
摘要:1 配置文件的方法 我们编写spring 框架的代码时候。一直遵循是这样一个规则:所有在spring中注入的bean 都建议定义成私有的域变量。并且要配套写上 get 和 set方法。 Boss 拥有 Office 和 Car 类型的两个属性: 清单 3. Boss.java <textarea c 阅读全文
posted @ 2016-07-03 23:45 乱世_独自美 阅读(105) 评论(0) 推荐(0)
摘要:事务的传播propagation属性 required(默认) 有事务则用,没事务则创建事务 not supported 不论有无事务,都不开启 requeresnew 不论有无事务,都创建启动新事务 mandatory 有事务则开启事务,没事务抛出异常 supports 有事务则开启事务,没事务就 阅读全文
posted @ 2016-06-21 11:03 乱世_独自美 阅读(301) 评论(0) 推荐(0)
摘要:Spring事务技术点: ThreadLocal,保证同一个线程是同一个连接 AOP,代理方式(拦截所有方法)+事务 实现:通过xml or 注解方式: 1) XML方式 >xml文件 <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http: 阅读全文
posted @ 2016-06-21 09:38 乱世_独自美 阅读(115) 评论(0) 推荐(0)
摘要:1) spring <bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> //这里 <property name="driverClassName" value="com. 阅读全文
posted @ 2016-06-19 17:29 乱世_独自美 阅读(1409) 评论(0) 推荐(0)
摘要:核心:JdbcTemplate对象包装了所有增删改查的操作 xml: <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataso 阅读全文
posted @ 2016-06-19 14:56 乱世_独自美 阅读(84) 评论(0) 推荐(0)
摘要:1) xml文件: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema 阅读全文
posted @ 2016-06-19 13:03 乱世_独自美 阅读(382) 评论(0) 推荐(0)
摘要:1)接口Waiter 2)实现类WaiterImp @Component("waiter") //扫描对象,对象名waiterpublic class WaiterImp implements Waiter{...} 3)通知类 @Aspect ///面切(拦截哪个方法)@Component //扫 阅读全文
posted @ 2016-06-17 11:00 乱世_独自美 阅读(65) 评论(0) 推荐(0)
摘要:Spring AOP注解方式自动代理需要aspectjweave.jar包 下载地址:http://cn.jarfire.org/aspectjweaver.html 阅读全文
posted @ 2016-06-16 18:52 乱世_独自美 阅读(178) 评论(0) 推荐(0)
摘要:jdk代理就是代理有接口的类 cglib代理是代理没有接口的类 代理就是拦截目标对象的所有方法,在方法前后执行一些代码,参考java之proxy jdk代理 接口类: public interface Waiter { public void greetTo(String name); public 阅读全文
posted @ 2016-06-16 14:03 乱世_独自美 阅读(85) 评论(0) 推荐(0)
摘要:类名报错The hierarchy of the type is inconsistent 这句话的意思是层次结构的类型是不一致的 public class BeforeGreeting implements MethodBeforeAdvice{...} 原因:缺少aopalliance.jar 阅读全文
posted @ 2016-06-16 12:47 乱世_独自美 阅读(169) 评论(0) 推荐(0)
摘要:Spring工厂的xml基础配置头尾: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001 阅读全文
posted @ 2016-06-13 16:37 乱世_独自美 阅读(193) 评论(0) 推荐(0)
摘要:下载页面不好找,特此标记 方法一: 直接进入下载链接 https://repo.spring.io/webapp/#/artifacts/browse/tree/Properties/libs-release-local/org/springframework/spring/3.2.2.RELEAS 阅读全文
posted @ 2016-06-12 19:13 乱世_独自美 阅读(149) 评论(0) 推荐(0)