随笔分类 -  spring

摘要:使用@Bean注解,在不配置destroyMethod时,其默认值为: 也就是在不配置destroyMethod时,spring会使用推断的销毁方法,这种推断的方法要求满足: 1. public的 2. 无参数 3. 方法名为close或shutdown 如果当一个bean正好有上面的方法,那么就会 阅读全文
posted @ 2019-05-29 15:24 raindream 阅读(3365) 评论(0) 推荐(1)
摘要:1: PROPAGATION_REQUIRED 加入当前正要执行的事务不在另外一个事务里,那么就起一个新的事务。比如说,ServiceB.methodB的事务级别定义为PROPAGATION_REQUIRED, 那么由于执行ServiceA.methodA的时候,ServiceA.methodA已经 阅读全文
posted @ 2017-03-06 23:59 raindream 阅读(139) 评论(0) 推荐(0)
摘要:转自:spring入门(六)【springMVC中各数据源配置】 && Spring下配置几种常用连接池 在使用spring进行javaWeb开发的过程中,需要和数据库进行数据交换,为此要经常获取数据库连接,使用JDBC的方式获取数据库连接,使用完毕之后再释放连接,这种过程对系统资源的消耗无疑是很大 阅读全文
posted @ 2016-12-06 22:37 raindream 阅读(1108) 评论(0) 推荐(0)
摘要:转自: Spring MVC 解读——<mvc:annotation-driven/> 摘自:使用@Controller注解为什么要配置<mvc:annotation-driven /> 摘要: <mvc:annotation-driven/>是做什么的?它做了什么?它与<context:compo 阅读全文
posted @ 2016-11-14 23:51 raindream 阅读(827) 评论(0) 推荐(0)
摘要:参考:http://docs.spring.io/spring/docs/current/spring-framework-reference/html/overview.html 阅读全文
posted @ 2016-11-08 23:20 raindream 阅读(701) 评论(0) 推荐(0)
摘要:Spring基于注解实现Bean定义支持如下三种注解: Spring自带的@Component注解及扩展@Repository、@Service、@Controller JSR-250 1.1版本中中定义的@ManagedBean注解,是Java EE 6标准规范之一,不包括在JDK中,需要在应用服 阅读全文
posted @ 2016-08-27 12:08 raindream 阅读(1950) 评论(0) 推荐(0)
摘要:AOP(Aspect-Oriented Programming,面向切面编程)是一种编程思想,并不是一种具体的实现,谈到实现一般有Filter和代理模式两种常见的使用方式。Java中常见的AOP技术有两个,分别是Filter和代理模式(也可以称为过滤器和拦截器),Filter是基于回调函数(请看《J 阅读全文
posted @ 2016-08-16 23:51 raindream 阅读(215) 评论(0) 推荐(0)
摘要:转自: Spring方法注入 引用 在大部分情况下,容器中的bean都是singleton类型的。如果一个singleton bean要引用另外一个singleton bean,或者一个非singleton bean要引用另外一个非singleton bean时,通常情况下将一个bean定义为另一个 阅读全文
posted @ 2016-08-06 17:17 raindream 阅读(408) 评论(0) 推荐(0)
摘要:1. ApplicationContext 不关闭,资源泄露问题: Spring ApplicationContext - Resource leak: 'context' is never closed 阅读全文
posted @ 2016-08-02 23:05 raindream 阅读(248) 评论(0) 推荐(0)
摘要:转自:也谈Spring Bean的生命周期 开篇先用一张老图描述下Spring中Bean容器的生命周期。 插叙一下,记得某个博文中提到:“Spring的Bean容器只管理非单例Bean的生命周期,单例Bean的生命周期不在管理范围内”,其实我认为这句话恰好说反了。首先明确一点,并非Spring容器中 阅读全文
posted @ 2016-07-31 17:30 raindream 阅读(1831) 评论(0) 推荐(0)
摘要:首先看配置文件: 这个文件中beans根节点下只有一个context:component-scan节点,此节点有两个属性base-package属性告诉spring要扫描的包,use-default-filters="false"表示不要使用默认的过滤器,此处的默认过滤器,会扫描包含Service, 阅读全文
posted @ 2016-07-31 14:07 raindream 阅读(953) 评论(0) 推荐(0)
摘要:Spring 利用PropertyPlaceholderConfigurer占位符 1. PropertyPlaceholderConfigurer是个bean工厂后置处理器的实现,也就是 BeanFactoryPostProcessor接口的一个实现。PropertyPlaceholderConf 阅读全文
posted @ 2016-07-30 20:59 raindream 阅读(445) 评论(0) 推荐(0)
摘要:转自:使用Spring 3的@value简化配置文件的读取 Spring 3支持@value注解的方式获取properties文件中的配置值,大简化了读取配置文件的代码。 1、在applicationContext.xml文件中配置properties文件 2、在bean中使用@value注解获取配 阅读全文
posted @ 2016-07-30 17:14 raindream 阅读(41202) 评论(0) 推荐(0)
摘要:转自:GOOD spring <context:annotation-config> 跟 <context:component-scan>诠释及区别 <context:annotation-config> 是用于激活那些已经在spring容器里注册过的bean(无论是通过xml的方式还是通过pack 阅读全文
posted @ 2016-07-30 14:05 raindream 阅读(352) 评论(0) 推荐(0)
摘要:转自:Spring <context:annotation-config/> 解说 在基于主机方式配置Spring的配置文件中,你可能会见到<context:annotation-config/>这样一条配置,他的作用是式地向 Spring 容器注册AutowiredAnnotationBeanPo 阅读全文
posted @ 2016-07-30 13:50 raindream 阅读(189) 评论(0) 推荐(0)
摘要:转自:Spring中@Autowired注解、@Resource注解的区别 Spring不但支持自己定义的@Autowired注解,还支持几个由JSR-250规范定义的注解,它们分别是@Resource、@PostConstruct以及@PreDestroy。 @Resource的作用相当于@Aut 阅读全文
posted @ 2016-07-30 13:25 raindream 阅读(270) 评论(0) 推荐(0)