- 浏览: 1488263 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (525)
- SEO (16)
- JAVA-EE-Hibernate (6)
- JAVA-EE-Struts (29)
- JAVA-EE-Spring (15)
- Linux (37)
- JAVA-SE (29)
- NetWork (1)
- CMS (14)
- Semantic Research (3)
- RIA-Flex (0)
- Ajax-Extjs (4)
- Ajax-Jquery (1)
- www.godaddy.com (0)
- SSH (34)
- JavaScript (6)
- SoftwareEngineer (9)
- CMMI (0)
- IDE-Myeclipse (3)
- PHP (1)
- Algorithm (3)
- C/C++ (18)
- Concept&Items (2)
- Useful WebSite (1)
- ApacheServer (2)
- CodeReading (1)
- Socket (2)
- UML (10)
- PowerDesigner (1)
- Repository (19)
- MySQL (3)
- SqlServer (0)
- Society (1)
- Tomcat (7)
- WebService (5)
- JBoss (1)
- FCKeditor (1)
- PS/DW/CD/FW (0)
- DesignPattern (11)
- WebSite_Security (1)
- WordPress (5)
- WebConstruction (3)
- XML|XSD (7)
- Android (0)
- Project-In-Action (9)
- DatabaseDesign (3)
- taglib (7)
- DIV+CSS (10)
- Silverlight (52)
- JSON (7)
- VC++ (8)
- C# (8)
- LINQ (1)
- WCF&SOA (5)
- .NET (20)
- SOA (1)
- Mashup (2)
- RegEx (6)
- Psychology (5)
- Stock (1)
- Google (2)
- Interview (4)
- HTML5 (1)
- Marketing (4)
- Vaadin (2)
- Agile (2)
- Apache-common (6)
- ANTLR (0)
- REST (1)
- HtmlAnalysis (18)
- csv-export (3)
- Nucth (3)
- Xpath (1)
- Velocity (6)
- ASP.NET (9)
- Product (2)
- CSS (1)
最新评论
-
lt26w:
理解成门面模式应该比较容易明白吧
FacadePattern-Java代码实例讲解 -
lt26w:
看下面的例子比较明白.
FacadePattern-Java代码实例讲解 -
javaloverkehui:
这也叫文档,别逗我行吗,也就自己看看。
HtmlCleaner API -
SE_XiaoFeng:
至少也应该写个注释吧。
HtmlCleaner API -
jfzshandong:
...
org.springframework.web.filter.CharacterEncodingFilter 配置
spring有三种启动方式,使用
- ContextLoaderServlet
- ContextLoaderListener
- ContextLoaderPlugIn
看一下ContextLoaderListener的源码,这是一个ServletContextListener
/** * Initialize the root web application context. */ public void contextInitialized(ServletContextEvent event) { this.contextLoader = createContextLoader(); this.contextLoader.initWebApplicationContext(event.getServletContext()); } /** * Create the ContextLoader to use. Can be overridden in subclasses. * @return the new ContextLoader */ protected ContextLoader createContextLoader() { return new ContextLoader(); } contextLoader的源码 public WebApplicationContext initWebApplicationContext(ServletContext servletContext) throws BeansException { long startTime = System.currentTimeMillis(); if (logger.isInfoEnabled()) { logger.info("Root WebApplicationContext: initialization started"); } servletContext.log("Loading Spring root WebApplicationContext"); try { // Determine parent for root web application context, if any. ApplicationContext parent = loadParentContext(servletContext); WebApplicationContext wac = createWebApplicationContext(servletContext, parent); servletContext.setAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); if (logger.isInfoEnabled()) { logger.info("Using context class [" + wac.getClass().getName() + "] for root WebApplicationContext"); } if (logger.isDebugEnabled()) { logger.debug("Published root WebApplicationContext [" + wac + "] as ServletContext attribute with name [" + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]"); } if (logger.isInfoEnabled()) { long elapsedTime = System.currentTimeMillis() - startTime; logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms"); } return wac; } catch (RuntimeException ex) { logger.error("Context initialization failed", ex); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); throw ex; } catch (Error err) { logger.error("Context initialization failed", err); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err); throw err; } } 注意WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,这里面放了WebApplicationContext,需要使用时从ServletContext取出 可以使用WebApplicationContextUtils得到WebApplicationContext public static WebApplicationContext getWebApplicationContext(ServletContext sc) { Object attr = sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (attr == null) { return null; } if (attr instanceof RuntimeException) { throw (RuntimeException) attr; } if (attr instanceof Error) { throw (Error) attr; } if (!(attr instanceof WebApplicationContext)) { throw new IllegalStateException("Root context attribute is not of type WebApplicationContext: " + attr); } return (WebApplicationContext) attr; } 关键的问题在于struts如何启动的spring的,ContextLoaderPlugIn的源码 // Publish the context as a servlet context attribute. String attrName = getServletContextAttributeName(); getServletContext().setAttribute(attrName, wac); public String getServletContextAttributeName() { return SERVLET_CONTEXT_PREFIX + getModulePrefix(); }
不同加载的Key竟然不同,原因就是WebApplicationContext放在那里的问题,可spring调用的时候会根据WebApplicationContext里面定义的那个名字去找的,问题出在这里
在struts-config.xml中配置
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" /> </plug-in> <controller> <set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor" /> </controller>
原理是这样的,Struts虽然只能有一个ActionServlet实例,但是对于不同的子应用分别能有自己的RequestProcessor实例每个RequestProcessor实例分别对应不同的struts配置文件。
子应用的ProcessorClass类必须重写一般就是继承RequestProcessor类,然后再其配置文件的controller元素中的<processorClass>属性中作出修改。那么当
getRequestProcessor(getModuleConfig(request)).process(request,response);
就能根据request选择相应的moduleconfig,再根据其<processorClass>属性选择相应的
RequestProcessor子类来处理相应的请求了。
==================
初探spring applicationContext在web容器中加载过程
转载自www.javaworld.com.tw
袁杰
原文
首先从WEB.XML入手
==>web.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<context-param> <param-name>webAppRootKey</param-name> <param-value>task.root</param-value> </context-param> <!-- 定义SPRING配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/taskContext*.xml</param-value> </context-param> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param> <!-- 定义LOG4J监听器 --> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <!-- 定义SPRING监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> |
进入contextLoaderListener看看到底加载时做了甚么
==>org.springframework.web.context.ContextLoaderListener
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
public class ContextLoaderListener implements ServletContextListener { private ContextLoader contextLoader; /** * Initialize the root web application context. */ //当WEB上下文初始化时,系统会调用此方法 public void contextInitialized(ServletContextEvent event) { this.contextLoader = createContextLoader(); //监听到WEB上下文初始化的时候执行SPRING上下文contextLoader的初始化工作 this.contextLoader.initWebApplicationContext(event.getServletContext()); } /** * Create the ContextLoader to use. Can be overridden in subclasses. * @return the new ContextLoader */ protected ContextLoader createContextLoader() { return new ContextLoader(); } /** * Return the ContextLoader used by this listener. */ public ContextLoader getContextLoader() { return contextLoader; } /** * Close the root web application context. */ public void contextDestroyed(ServletContextEvent event) { if (this.contextLoader != null ) { this.contextLoader.closeWebApplicationContext(event.getServletContext()); } } } |
看一下是怎么来初始化webapplicationContext的
==>contextLoader.initWebApplicationContext
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
public WebApplicationContext initWebApplicationContext(ServletContext servletContext) throws IllegalStateException, BeansException { if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null ) { throw new IllegalStateException( "Cannot initialize context because there is already a root application context present - " + "check whether you have multiple ContextLoader* definitions in your web.xml!" ); } long startTime = System.currentTimeMillis(); if (logger.isInfoEnabled()) { logger.info("Root WebApplicationContext: initialization started" ); } servletContext.log("Loading Spring root WebApplicationContext" ); try { // Determine parent for root web application context, if any. ApplicationContext parent = loadParentContext(servletContext); // Store context in local instance variable, to guarantee that // it is available on ServletContext shutdown. //创建web上下文 this.context = createWebApplicationContext(servletContext, parent); servletContext.setAttribute( WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context); if (logger.isInfoEnabled()) { logger.info("Using context class [" + this.context.getClass().getName() + "] for root WebApplicationContext" ); } if (logger.isDebugEnabled()) { logger.debug("Published root WebApplicationContext [" + this.context + "] as ServletContext attribute with name [" + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]" ); } if (logger.isInfoEnabled()) { long elapsedTime = System.currentTimeMillis() - startTime; logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms"); } return this.context; } catch (RuntimeException ex) { logger.error("Context initialization failed" , ex); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); throw ex; } catch (Error err) { logger.error("Context initialization failed" , err); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err); throw err; } } |
==>contextLoader.createWebApplicationContext(servletContext, parent);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
protected WebApplicationContext createWebApplicationContext( ServletContext servletContext, ApplicationContext parent) throws BeansException { //根据servletContext来决定要实例化的WebApplicationContext Class contextClass = determineContextClass(servletContext); if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) { throw new ApplicationContextException("Custom context class [" + contextClass.getName() + "] is not of type ConfigurableWebApplicationContext" ); } ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass); wac.setParent(parent); wac.setServletContext(servletContext); //得到WEB.XML中设置的SPRING配置文件位置 String configLocation = servletContext.getInitParameter(CONFIG_LOCATION_PARAM); if (configLocation != null ) { //把配置文件分段后设置到WebApplicationContext的ConfigLocations中 wac.setConfigLocations(StringUtils.tokenizeToStringArray(configLocation, ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS)); } //刷新WebApplicationContext wac.refresh(); return wac; } |
==>contextLoader.determineContextClass(servletContext);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
protected Class determineContextClass(ServletContext servletContext) throws ApplicationContextException { //获得需要实例化的CONTEXT类名,在web.xml中有设置,如果没有设置,那么为空 String contextClassName = servletContext.getInitParameter(CONTEXT_CLASS_PARAM); if (contextClassName != null ) { try { return ClassUtils.forName(contextClassName); } catch (ClassNotFoundException ex) { throw new ApplicationContextException( "Failed to load custom context class [" + contextClassName + "]" , ex); } } //如果在spring web.xml中没有设置context类位置,那么取得默认context else { //取得defaultStrategies配置文件中的WebApplicationContext属性 contextClassName = defaultStrategies.getProperty(WebApplicationContext.class.getName()); try { return ClassUtils.forName(contextClassName); } catch (ClassNotFoundException ex) { throw new ApplicationContextException( "Failed to load default context class [" + contextClassName + "]" , ex); } } } |
SPRING上下文默认的策略是甚么呢?
==>contextLoader.defaultStrategies
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
private static final Properties defaultStrategies; static { // Load default strategy implementations from properties file. // This is currently strictly internal and not meant to be customized // by application developers. try { //设置classpath为contextLoader同级目录 ClassPathResource resource = new ClassPathResource(DEFAULT_STRATEGIES_PATH, ContextLoader.class); //加载该目录下的所有properties文件 defaultStrategies = PropertiesLoaderUtils.loadProperties(resource); } catch (IOException ex) { throw new IllegalStateException("Could not load 'ContextLoader.properties': " + ex.getMessage()); } } |
找到同级目录下的配置文件
==>ContextLoader.properties
1
2
3
4
5
6
7
8
|
# Default WebApplicationContext implementation class for ContextLoader. # Used as fallback when no explicit context implementation has been specified as context-param. # Not meant to be customized by application developers. #默认的WebApplicationContext为org.springframework.web.context.support.XmlWebApplicationContext org.springframework.web.context.WebApplicationContext=org.springframework.web.context.support.XmlWebApplicationContext |
==>org.springframework.web.context.support.XmlWebApplicationContext
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
public class XmlWebApplicationContext extends AbstractRefreshableWebApplicationContext { /** Default config location for the root context */ //配置了默认的spring配置文件 public static final String DEFAULT_CONFIG_LOCATION = "/WEB-INF/applicationContext.xml" ; //配置文件默认BUILD路径 public static final String DEFAULT_CONFIG_LOCATION_PREFIX = "/WEB-INF/" ; //配置文件默认后缀名 public static final String DEFAULT_CONFIG_LOCATION_SUFFIX = ".xml" ; /** * Loads the bean definitions via an XmlBeanDefinitionReader. * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader * @see #initBeanDefinitionReader * @see #loadBeanDefinitions */ //获得bean配置 protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException { //从BEAN工厂获得一个XmlBeanDefinitionReader 来读取SPRING配置文件 XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); //设置beanDefinitionReader服务于当前CONTEXT // resource loading environment. beanDefinitionReader.setResourceLoader(this ); beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this )); // Allow a subclass to provide custom initialization of the reader, // then proceed with actually loading the bean definitions. initBeanDefinitionReader(beanDefinitionReader); //读取配置文件 loadBeanDefinitions(beanDefinitionReader); } /** * Initialize the bean definition reader used for loading the bean * definitions of this context. Default implementation is empty. * <p>Can be overridden in subclasses, e.g. for turning off XML validation * or using a different XmlBeanDefinitionParser implementation. * @param beanDefinitionReader the bean definition reader used by this context * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader#setValidationMode * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader#setDocumentReaderClass */ protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) { } /** * Load the bean definitions with the given XmlBeanDefinitionReader. * <p>The lifecycle of the bean factory is handled by the refreshBeanFactory method; * therefore this method is just supposed to load and/or register bean definitions. * <p>Delegates to a ResourcePatternResolver for resolving location patterns * into Resource instances. * @throws org.springframework.beans.BeansException in case of bean registration errors * @throws java.io.IOException if the required XML document isn't found * @see #refreshBeanFactory * @see #getConfigLocations * @see #getResources * @see #getResourcePatternResolver */ //读取配置文件 protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException { String[] configLocations = getConfigLocations(); if (configLocations != null ) { for (int i = 0; i < configLocations.length; i++) { reader.loadBeanDefinitions(configLocations[i]); } } } /** * The default location for the root context is "/WEB-INF/applicationContext.xml", * and "/WEB-INF/test-servlet.xml" for a context with the namespace "test-servlet" * (like for a DispatcherServlet instance with the servlet-name "test"). */ //获得默认的ConfigLocations protected String[] getDefaultConfigLocations() { if (getNamespace() != null ) { return new String[] { DEFAULT_CONFIG_LOCATION_PREFIX + getNamespace() + DEFAULT_CONFIG_LOCATION_SUFFIX} ; } else { return new String[] { DEFAULT_CONFIG_LOCATION} ; } } |
==>AbstractBeanDefinitionReader.loadBeanDefinitions()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
public int loadBeanDefinitions(String location) throws BeanDefinitionStoreException { ResourceLoader resourceLoader = getResourceLoader(); if (resourceLoader == null ) { throw new BeanDefinitionStoreException( "Cannot import bean definitions from location [" + location + "]: no ResourceLoader available" ); } if (resourceLoader instanceof ResourcePatternResolver) { // Resource pattern matching available. try { //根据配置文件读取相应配置 Resource[] resources = ((ResourcePatternResolver) resourceLoader).getResources(location); int loadCount = loadBeanDefinitions(resources); if (logger.isDebugEnabled()) { logger.debug("Loaded " + loadCount + " bean definitions from location pattern [" + location + "]" ); } return loadCount; } catch (IOException ex) { throw new BeanDefinitionStoreException( "Could not resolve bean definition resource pattern [" + location + "]" , ex); } } else { // Can only load single resources by absolute URL. Resource resource = resourceLoader.getResource(location); int loadCount = loadBeanDefinitions(resource); if (logger.isDebugEnabled()) { logger.debug("Loaded " + loadCount + " bean definitions from location [" + location + "]" ); } return loadCount; } } |
这个是其中一个ResourceLoader的实现
==>PathMatchingResourcePatternResolver.getResources(String locationPattern);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
public Resource[] getResources(String locationPattern) throws IOException { Assert.notNull(locationPattern, "Location pattern must not be null" ); if (locationPattern.startsWith(CLASSPATH_ALL_URL_PREFIX)) { // a class path resource (multiple resources for same name possible) if (getPathMatcher().isPattern(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length()))) { // a class path resource pattern return findPathMatchingResources(locationPattern); } else { // all class path resources with the given name return findAllClassPathResources(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length())); } } else { // Only look for a pattern after a prefix here // (to not get fooled by a pattern symbol in a strange prefix). int prefixEnd = locationPattern.indexOf(":" ) + 1; if (getPathMatcher().isPattern(locationPattern.substring(prefixEnd))) { // a file pattern return findPathMatchingResources(locationPattern); } else { // a single resource with the given name return new Resource[] { getResourceLoader().getResource(locationPattern)} ; } } } |
==>PathMatchingResourcePatternResolver.findPathMatchingResources(String locationPattern);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
protected Resource[] findPathMatchingResources(String locationPattern) throws IOException { String rootDirPath = determineRootDir(locationPattern); String subPattern = locationPattern.substring(rootDirPath.length()); Resource[] rootDirResources = getResources(rootDirPath); //collectionFactory初始化一个set容量为16 Set result = CollectionFactory.createLinkedSetIfPossible(16); for (int i = 0; i < rootDirResources.length; i++) { Resource rootDirResource = rootDirResources[i]; if (isJarResource(rootDirResource)) { result.addAll(doFindPathMatchingJarResources(rootDirResource, subPattern)); } else { result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern)); } } if (logger.isDebugEnabled()) { logger.debug("Resolved location pattern [" + locationPattern + "] to resources " + result); } return (Resource[]) result.toArray(new Resource[result.size()]); } |
前面说到有一个刷新WebApplicationContext的操作,但是XmlWebApplicationContext 并没有实现refresh方法,而方法的实现写在
AbstractRefreshableWebApplicationContext 中
==>AbstractRefreshableWebApplicationContext.refresh();
1
2
3
4
5
6
7
|
public void refresh() throws BeansException { if (ObjectUtils.isEmpty(getConfigLocations())) { //设置configLocations为默认的getDefaultConfigLocations() setConfigLocations(getDefaultConfigLocations()); } super.refresh(); } |
==>AbstractApplicationContext.refresh();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
public void refresh() throws BeansException, IllegalStateException { synchronized (this.startupShutdownMonitor) { this.startupTime = System.currentTimeMillis(); synchronized (this.activeMonitor) { this.active = true ; } // Tell subclass to refresh the internal bean factory. refreshBeanFactory(); ConfigurableListableBeanFactory beanFactory = getBeanFactory(); // Tell the internal bean factory to use the context's class loader. beanFactory.setBeanClassLoader(getClassLoader()); // Populate the bean factory with context-specific resource editors. beanFactory.addPropertyEditorRegistrar(new ResourceEditorRegistrar(this )); // Configure the bean factory with context semantics. beanFactory.addBeanPostProcessor(new ApplicationContextAwareProcessor(this )); beanFactory.ignoreDependencyInterface(ResourceLoaderAware.class); beanFactory.ignoreDependencyInterface(ApplicationEventPublisherAware.class); beanFactory.ignoreDependencyInterface(MessageSourceAware.class); beanFactory.ignoreDependencyInterface(ApplicationContextAware.class); // Allows post-processing of the bean factory in context subclasses. postProcessBeanFactory(beanFactory); // Invoke factory processors registered with the context instance. for (Iterator it = getBeanFactoryPostProcessors().iterator(); it.hasNext();) { BeanFactoryPostProcessor factoryProcessor = (BeanFactoryPostProcessor) it.next(); factoryProcessor.postProcessBeanFactory(beanFactory); } if (logger.isInfoEnabled()) { if (getBeanDefinitionCount() == 0) { logger.info("No beans defined in application context [" + getDisplayName() + "]" ); } else { logger.info(getBeanDefinitionCount() + " beans defined in application context [" + getDisplayName() + "]" ); } } try { // Invoke factory processors registered as beans in the context. invokeBeanFactoryPostProcessors(); // Register bean processors that intercept bean creation. registerBeanPostProcessors(); // Initialize message source for this context. initMessageSource(); // Initialize event multicaster for this context. initApplicationEventMulticaster(); // Initialize other special beans in specific context subclasses. onRefresh(); // Check for listener beans and register them. registerListeners(); // Instantiate singletons this late to allow them to access the message source. beanFactory.preInstantiateSingletons(); // Last step: publish corresponding event. publishEvent(new ContextRefreshedEvent(this )); } catch (BeansException ex) { // Destroy already created singletons to avoid dangling resources. beanFactory.destroySingletons(); throw ex; } } } http://www.blogjava.net/run2u/archive/2007/11/07/158824.html |
发表评论
-
java.lang.ClassCastException: java.lang.Integer
2010-01-09 12:55 1357java.lang.ClassCastException: j ... -
Error:org.springframework.web.context.ContextLoaderListener
2010-01-06 21:17 8664Error con ... -
Error configuring application listener of class org.springframework.web.context.
2010-01-06 21:11 20096急!!tomcat启动报错:Error configuring ... -
Cannot find bean org.apache.struts.taglib.html.BEAN
2009-12-29 14:29 1272Cannot find bean org.apache.str ... -
attempt to create delete event with null entity
2009-12-29 11:07 4648attempt to create delete event ... -
懒加载异常org.hibernate.LazyInitializationException: could not initialize proxy - no
2009-12-28 20:44 20177错误页面提示 could n ... -
getHibernateTemplate.load() 和get()之间的区别
2009-12-28 20:16 18441. getHibernateTemplate.load() ... -
getSession()与getHibernateTemplate()区别
2009-12-28 20:13 2538getSession()与getHibernateTempla ... -
使用Hibernate持久层 --- 2 出现的问题与解决方法总结
2009-12-28 15:04 1178使用Hibernate持久层 --- 2 出现的问题与解决方法 ... -
java.lang.NullPointerException DAO
2009-12-28 15:02 1814~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... -
JSTL1.1中要用的jar--standard.jar jstl.jar
2009-12-09 00:35 4040gg -
Jsessionid
2009-12-07 16:22 1253(1) 这是一个 ... -
ContextLoaderListener VS. ContextLoaderServlet
2009-12-07 15:20 3525一旦ContextLoaderServlet或Cont ... -
ERRORcheck whether you have multiple ContextLoader* definitions in your web.xml!
2009-12-07 15:17 6222ERROR:check whether you have mu ... -
从tomcat 迁移到 WebSphere 经验总结(修改)
2009-12-07 15:08 2411从tomcat 迁移到 WebSphere ... -
CGlib & asm
2009-12-07 15:01 2687缺少包出现的错误信息:cglib-2.1.3.jar CGL ... -
Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTup
2009-12-07 14:57 5418Unable to instantiate default t ... -
asm.jar的冲突问题
2009-12-07 14:53 1456No configuration found. Confi ... -
异常:ERROR [org.hibernate.proxy.BasicLazyInitializer] - CGLIB Enhancement failed..
2009-12-07 14:25 1765用MyEclipse6.0写了一个spri ... -
ssh 整合时报错java.lang.reflect.InvocationTargetException... 但是能运行起[
2009-12-07 14:17 11796内容太长(多次发): [Tomcat]2007-09-0 ...
相关推荐
spring boot三种启动方式.txt
spring配置和启动方式 博客地址:https://blog.csdn.net/u010476739/article/details/76696756
Spring启动完整流程图 Spring启动完整流程图 Spring启动完整流程图 Spring启动完整流程图 Spring启动完整流程图 Spring启动完整流程图 Spring启动完整流程图 Spring启动完整流程图 Spring启动完整流程图 Spring启动...
springboot项目中静态方法中使用spring托管的三种类方式
针对spring framework的xml配置 注解配置 做了简单示例
spring boot windows 启动脚本
1. Spring容器的启动流程 2. 循环依赖 3. Spring 中Bean的创建 4. Spring 方法xmind脑图
spring容器启动和关闭时事件监听;spring容器启动和关闭时事件监听;spring容器启动和关闭时事件监听
spring+hibernate启动优化
linux服务器,springboot,spring cloud、spring cloud alibaba等项目启动脚本 下载脚本, 1,上传脚本至jar包同级目录 2,更改脚本: jar包名称 项目文件路径 日志路径(包含日志名称) 脚本已配置好jvm优化...
SpringCloud微服务架构,启动脚本,动态输出日志,并指向启动日志脚本位置。
demo spring 3.0 mvc
Linux部署springboot(springcloud),一次启动多个jar并按照日期输出日志文件。启动运行restart.sh,停止运行stop.sh
描述了Spring在容器在启动的时候发生了什么
jenkins启动spring boot 服务shll启动脚本 主要是备份原来的服务,kill掉重新部署
Spring boot开启定时任务的三种方式 零、前言 第一种也就是最简单的一种:基于注解 (@Scheduled)的方式; 第二种:基于接口 (SchedulingConfigurer); 第三种:基于注解设定多线程定时任务。 一、基于@Scheduled注解...
spring启动.txt 详细介绍Spring 在tomcat容器里的启动过程
定时启动--启动按钮(spring注入)
springMVC中启动netty
Spring源代码解析(二):ioc容器在Web容器中的启动 Spring源代码分析(三):Spring JDBC Spring源代码解析(四):Spring MVC Spring源代码解析(五):Spring AOP获取Proxy Spring源代码解析(六):Spring声明式事务处理...