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

浙公网安备 33010602011771号