
Spring
new03
这个作者很懒,什么都没留下…
展开
-
Spring @Import注解
@Import注解在4.2之前只支持导入配置类;在4.2以及之后,@Import注解支持导入普通java类,并将其声明成一个bean。 业务类:public class DemoService { public void doSomething(){ System.out.println("everything is all fine"); }...原创 2017-05-10 14:36:11 · 272 阅读 · 0 评论 -
Spring WebApplicationInitializer
Servlet3.0之后,提供了注解,使得不需要在web.xml中进行servlet的配置。 在原web.xml中,<load-on-startup>1</load-on-startup>的作用:1)load-on-startup元素标记容器是否在启动的时候就加载这个servlet(实例化并调用其init()方法)。2)它的值必须是一个整数,表示serv...原创 2017-05-11 10:32:42 · 291 阅读 · 0 评论 -
Servlet 3.0 contextLoadListener和WebAppRootListener
ContextLoadListener:它会默认查找位于:WEB-INF/下的是否有一个文件名称为:applicationContext.xml的文件。如果要加载其它spring配置文件,web.xml配置:<context-param> <param-name> contextConfigLocation &...原创 2017-05-12 10:57:52 · 155 阅读 · 0 评论 -
Spring 中Bean及@Bean的理解
注解凡是拥有子类及带有方法或属性的类都要加上注解注册Bean到Spring IoC中。我们在微博上@某某,对方会优先看到这条信息,并给你反馈,那么在Spring中,你标识一个@符号,那么Spring就会来看看,并且从这里拿到一个Bean或者给出一个Bean 使用Bean的注解即是把已经在xml文件中配置好的Bean拿来用,完成属性、方法的组装;比如@Autowired , @...原创 2017-05-15 09:51:28 · 178 阅读 · 0 评论 -
spring 监听器 IntrospectorCleanupListener简介
引用关于IntrospectorCleanupListener一段解释:在服务器运行过程中,Spring不停的运行的计划任务和OpenSessionInViewFilter,使得Tomcat反复加载对象而产生框架并用时可能产生的内存泄漏,则使用IntrospectorCleanupListener作为相应的解决办法。Spring中的提供了一个名为org.springframework....原创 2017-05-23 11:48:02 · 107 阅读 · 0 评论 -
Spring 中 @Autowired与@Resource的区别
1、@Autowired与@Resource都是做bean的注入时使用,都可以用来装配bean, 都可以写在字段上,或写在setter方法上。 2、@Autowired默认按类型装配(这个注解属于spring),默认情况下必须要求依赖对象必须存在,如果要允许null值,可以设置它的required属性为false。如:@Autowired(required=false) ,如果我们想...原创 2017-09-06 10:03:22 · 279 阅读 · 0 评论