请看下面是控制台输入的日志:
这是第一次的:
一月 20, 2017 8:33:22 上午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
一月 20, 2017 8:33:22 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2017-01-20 08:33:22,868 0 [ost-startStop-1] INFO work.web.context.ContextLoader - Root WebApplicationContext: initialization started
2017-01-20 08:33:23,009 141 [ost-startStop-1] INFO pport.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Fri Jan 20 08:33:23 CST 2017]; root of context hierarchy
2017-01-20 08:33:23,072 204 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml]
2017-01-20 08:33:23,446 578 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [jar:file:/E:/tomcat/apache-tomcat-7.0.52/webapps/business-web/WEB-INF/lib/business-dao-0.0.1-SNAPSHOT.jar!/spring/applicationContext-dao.xml]
2017-01-20 08:33:23,462 594 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [jar:file:/E:/tomcat/apache-tomcat-7.0.52/webapps/business-web/WEB-INF/lib/business-service-0.0.1-SNAPSHOT.jar!/spring/applicationContext-service.xml]
这是第二次的:一月 20, 2017 8:33:30 上午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory E:\tomcat\apache-tomcat-7.0.52\webapps\business-web
一月 20, 2017 8:33:33 上午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
一月 20, 2017 8:33:34 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2017-01-20 08:33:34,031 0 [ost-startStop-1] INFO work.web.context.ContextLoader - Root WebApplicationContext: initialization started
2017-01-20 08:33:34,126 95 [ost-startStop-1] INFO pport.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Fri Jan 20 08:33:34 CST 2017]; root of context hierarchy
2017-01-20 08:33:34,172 141 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml]
2017-01-20 08:33:34,703 672 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [jar:file:/E:/tomcat/apache-tomcat-7.0.52/webapps/business-web/WEB-INF/lib/business-dao-0.0.1-SNAPSHOT.jar!/spring/applicationContext-dao.xml]
2017-01-20 08:33:34,718 687 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [jar:file:/E:/tomcat/apache-tomcat-7.0.52/webapps/business-web/WEB-INF/lib/business-service-0.0.1-SNAPSHOT.jar!/spring/applicationContext-service.xml]
2017-01-20 08:33:34,734 703 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring/applicationContext-action.xml]是我的项目有什么问题吗?我用的是SSH框架,但是其他SSH框架就没有这个问题.
这是第一次的:
一月 20, 2017 8:33:22 上午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
一月 20, 2017 8:33:22 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2017-01-20 08:33:22,868 0 [ost-startStop-1] INFO work.web.context.ContextLoader - Root WebApplicationContext: initialization started
2017-01-20 08:33:23,009 141 [ost-startStop-1] INFO pport.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Fri Jan 20 08:33:23 CST 2017]; root of context hierarchy
2017-01-20 08:33:23,072 204 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml]
2017-01-20 08:33:23,446 578 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [jar:file:/E:/tomcat/apache-tomcat-7.0.52/webapps/business-web/WEB-INF/lib/business-dao-0.0.1-SNAPSHOT.jar!/spring/applicationContext-dao.xml]
2017-01-20 08:33:23,462 594 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [jar:file:/E:/tomcat/apache-tomcat-7.0.52/webapps/business-web/WEB-INF/lib/business-service-0.0.1-SNAPSHOT.jar!/spring/applicationContext-service.xml]
这是第二次的:一月 20, 2017 8:33:30 上午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory E:\tomcat\apache-tomcat-7.0.52\webapps\business-web
一月 20, 2017 8:33:33 上午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
一月 20, 2017 8:33:34 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2017-01-20 08:33:34,031 0 [ost-startStop-1] INFO work.web.context.ContextLoader - Root WebApplicationContext: initialization started
2017-01-20 08:33:34,126 95 [ost-startStop-1] INFO pport.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Fri Jan 20 08:33:34 CST 2017]; root of context hierarchy
2017-01-20 08:33:34,172 141 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml]
2017-01-20 08:33:34,703 672 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [jar:file:/E:/tomcat/apache-tomcat-7.0.52/webapps/business-web/WEB-INF/lib/business-dao-0.0.1-SNAPSHOT.jar!/spring/applicationContext-dao.xml]
2017-01-20 08:33:34,718 687 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [jar:file:/E:/tomcat/apache-tomcat-7.0.52/webapps/business-web/WEB-INF/lib/business-service-0.0.1-SNAPSHOT.jar!/spring/applicationContext-service.xml]
2017-01-20 08:33:34,734 703 [ost-startStop-1] INFO ry.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring/applicationContext-action.xml]是我的项目有什么问题吗?我用的是SSH框架,但是其他SSH框架就没有这个问题.
解决方案 »
- jsp<%%>中使用S2标签
- 如何把java的数组的值给javascript?
- session 缓存问题
- MD5加密类原因~ 请高人直接代码错误
- struts的<html:select></html:select>标签请教
- struts配置validation为什么报错啊?抽空帮我看看
- java初级问题
- 网站后台上传图片问题
- Apache的Common-pool中的Object pool的疑问,怎么比不用object pool要慢很多阿?!多谢!
- sessionbean+hibernate+weblogic+sqlserver查询时报错
- 请问这个图是什么问题?eclipse,版本是对的啊!
- mysql数据库 我该如何做关联查询
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"> <!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
--> <!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/> <Context docBase="E:\upload" path="/images" reloadable="true"/><Context docBase="E:\tomcat\apache-tomcat-7.0.52\webapps\springmvcweb3.0" path="/springmvcweb3.0" reloadable="false" source="org.eclipse.jst.jee.server:springmvcweb3.0"/></Host>
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
--> <!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." suffix=".txt"/> <Context docBase="E:\upload" path="/images" reloadable="true"/><Context docBase="E:\tomcat\apache-tomcat-7.0.52\webapps\business-web" path="/business" reloadable="false" source="org.eclipse.jst.jee.server:business-web"/></Host>
前提: 1、存在某个应用:hello 2、该应用存放路径:D:/apache-tomcat-5.5.17/webapps/hello 3、Tomcat的server.xml部分配置信息如下:...<Context path="" reloadable="true" docBase="hello"/>... (这么做的目的就是为了将hello应用设为根,访问IP时就直接访问该应用) 4、hello下有一个 servlet(目的是为了系统在启动时执行某些初始化的操作),该servlet里存在init()方法,目前该方法里只打印“hello word”字符串; 5、hello 应用的 web.xml 部分配置信息如下: <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>HelloServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> 问题: 在启动 tomcat5 时,控制台窗口会打印出两行“hello word”字符串? 问题原因: 因为hello应用本来就放在Tomat的默认webapp目录下(tomcat在启动时肯定会加载1次),然后又在server.xml中做了配置,为了达到访问根就可以访问hello应用(这样tomcat就又加载1次);结果,Tomcat就会加载两次。 解决办法: 办法1、不要将 hello 应用放在Tomat的默认webapp目录下,把它移出去,然后在server.xml中修改docBase的值为hello应用在新位置的绝对路径就可以了; 办法2、删除掉server.xml中 Context 的手动配置,这样就不会加载两次,因为hello应用在webapp下,所以在访问时,就只能是:http://ip:port/hello 这样来访问了。这是我引用过来的,大概的意思就是要你去修改下server.xml的配置,我这边的项目按照第一种办法实现的
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
前提: 1、存在某个应用:hello 2、该应用存放路径:D:/apache-tomcat-5.5.17/webapps/hello 3、Tomcat的server.xml部分配置信息如下:...<Context path="" reloadable="true" docBase="hello"/>... (这么做的目的就是为了将hello应用设为根,访问IP时就直接访问该应用) 4、hello下有一个 servlet(目的是为了系统在启动时执行某些初始化的操作),该servlet里存在init()方法,目前该方法里只打印“hello word”字符串; 5、hello 应用的 web.xml 部分配置信息如下: <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>HelloServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> 问题: 在启动 tomcat5 时,控制台窗口会打印出两行“hello word”字符串? 问题原因: 因为hello应用本来就放在Tomat的默认webapp目录下(tomcat在启动时肯定会加载1次),然后又在server.xml中做了配置,为了达到访问根就可以访问hello应用(这样tomcat就又加载1次);结果,Tomcat就会加载两次。 解决办法: 办法1、不要将 hello 应用放在Tomat的默认webapp目录下,把它移出去,然后在server.xml中修改docBase的值为hello应用在新位置的绝对路径就可以了; 办法2、删除掉server.xml中 Context 的手动配置,这样就不会加载两次,因为hello应用在webapp下,所以在访问时,就只能是:http://ip:port/hello 这样来访问了。这是我引用过来的,大概的意思就是要你去修改下server.xml的配置,我这边的项目按照第一种办法实现的不会吧..这么麻烦..我是直接用eclipse的tomcat插件运行的,但是我运行其他的SSH项目就只加载一次spring配置文件啊??
如果只有一个项目,那么用楼上兄弟的方法可行,但是如果有两上或者以上项目,则需要这样修改:
项目名称: projectA,projectB,A需要在根目录访问
容器目录: /opt/tomcat/
将projectA放到/opt/tomcat/projectA,将projectB放到默认目录/opt/tomcat/webapps
接着更改server.xml,在host处设置如下:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" reloadable="false" docBase="/opt/tomcat/projectA"/>
原理:因为projectA不在webapps目录下,所以只会加载一次而不会重复加载。