摘要: spring容器中的bean默认是单例模式的,改成非单例模式需要在类上加上@Scope("prototype") 1. scope概论 spring中scope是一个非常关键的概念,简单说就是对象在spring容器(IOC容器)中的生命周期,也可以理解为对象在spring容器中的创建方式。 2. s 阅读全文
posted @ 2018-06-07 13:46 谁将新樽辞旧月,今月曾经照古人 阅读(766) 评论(0) 推荐(0) 编辑
摘要: @Configuration public class DruidConfiguration { @Bean public ServletRegistrationBean statViewServlet() { ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBea... 阅读全文
posted @ 2018-06-07 05:49 谁将新樽辞旧月,今月曾经照古人 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Spring不但支持自己定义的@Autowired注解,还支持由JSR-250规范定义的几个注解。如:@Resource、@PostConstruct及@PreDestroy 1、@Autowired 由Spring提供,只按照byType注入 2、@Resource 由J2EE提供,默认按照byN 阅读全文
posted @ 2018-06-07 05:49 谁将新樽辞旧月,今月曾经照古人 阅读(127) 评论(0) 推荐(0) 编辑