如果spring--bean是单例,那么web项目一启动就会加载到内存,如果bean是多例,项目会在刚刚使用的时候,就是走到这个请求地址的时候,类才会加载---spring 默认为单例
来源:互联网 发布:知乎机构号 编辑:程序博客网 时间:2024/05/20 21:21
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by Administrator on 14-4-9.
*
* @author leizhimin 14-4-9 上午10:55
*/
@Controller
@RequestMapping("/demo/lsh/ch5")
@Scope("prototype")
public class MultViewController {
private static int st = 0; //静态的
private int index = 0; //非静态
static{
System.out.println("if i apear first, i am single");
}
@RequestMapping("/test")
public String test() {
System.out.println(st++ + " | " + index++);
return "/lsh/ch5/test";
}
}
如果spring--bean是单例,那么web项目一启动就会加载到内存,如果bean是多例,项目会在刚刚使用的时候,就是走到这个请求地址的时候,类才会加载
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by Administrator on 14-4-9.
*
* @author leizhimin 14-4-9 上午10:55
*/
@Controller
@RequestMapping("/demo/lsh/ch5")
@Scope("prototype")
public class MultViewController {
private static int st = 0; //静态的
private int index = 0; //非静态
static{
System.out.println("if i apear first, i am single");
}
@RequestMapping("/test")
public String test() {
System.out.println(st++ + " | " + index++);
return "/lsh/ch5/test";
}
}
如果spring--bean是单例,那么web项目一启动就会加载到内存,如果bean是多例,项目会在刚刚使用的时候,就是走到这个请求地址的时候,类才会加载
0 0
- 如果spring--bean是单例,那么web项目一启动就会加载到内存,如果bean是多例,项目会在刚刚使用的时候,就是走到这个请求地址的时候,类才会加载---spring 默认为单例
- 在Maven项目中加载spring中的bean的配置xml文件会提示找不到解决方法
- 在项目中用到datatables比较多,但是当datatables加载超过1000多的时候就会出现有点缓慢的的样子,这个时候如果继续增加数据量让datatables去处理,那会是一个让人抓狂的事情,幸
- Bean第一次从容器获取的时候,如果bean配置了lookup-method,那么就使用了cglib来进行调用方法转换
- web.xml文件加载顺序 一、 1 、启动一个 WEB 项目的时候, WEB 容器会去读取它的配置文件 web.xml ,读取 <listener> 和 <context-param>
- spring bean的加载
- spring的bean加载
- 对象是从xib/storybard加载的时候,就会调用这个方法initWithCoder:(NSCoder *)aDecoder
- Spring声明事务的时候如果代码中有commit会发生什么
- spring-data-jpa 中,如果使用了one-to-many , many-to-one的注释,会在Jackson进行json字符串化的时候出现错误
- SPRING 启动加载BEAN 的代码过程
- Spring源码之bean的加载(一)
- spring源代码之bean的加载(一)
- 服务器启动的时候,如何加载spring?
- 在加载Android studio程序的时候,会爆出这个的错误的解决方式
- Spring源码之bean的加载(四)获取单例
- SSH框架,在项目启动的时候加载数据库信息
- Spring IOC-Servlet加载到bean工厂
- LaTeX学习教程
- linux系统:"ping: unknown host www.baidu.com"
- 使用Maven构建一个简单的java工程
- socket编程之select()
- C++的static静态变量
- 如果spring--bean是单例,那么web项目一启动就会加载到内存,如果bean是多例,项目会在刚刚使用的时候,就是走到这个请求地址的时候,类才会加载---spring 默认为单例
- DWR中监听器类找不到的解决方案
- 在VMware中为CentOS配置静态ip并可访问网络-windows下的VMware
- 为什么有的ios开发证书没有秘钥
- 工程师总结:信号完整性设计经验50条(一)
- UML笔记4--状态图
- LeetCode 9.Palindrome Number
- C++标准库---迭代器失效之正确的插入和移除元素
- AFNetworking 2.0 - 游贤明