tomcat发布多个项目

最近在项目中需要在tomcat中发布多个web项目,在启动的时候发生报错,报错信息如下:

java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [....\tmp1\wtpwebapps\workreport\] instead of [.....\wtpwebapps\ApprovalFront\] 
- Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
    at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:150)
    at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:116)
    at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:45)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

通过报错信息加上百度查询,原来web项目发布多个时,需要在web.xml中定义唯一的webAppRootKey,解决办法:
在每个web项目中的web.xml文件中定义webAppRootKey属性,如下:、

 <!--web1中的web.xml-->
<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>ysdq-web</param-value>
</context-param>

<!--web2中的web.xml-->
<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>ysdq-web-in</param-value>
</context-param>

此外,在运行web项目时经常遇到以下问题:
Resource is out of sync with the file system
主要原因:文件系统不同步造成的
解决办法:
选中工程,右键,选择F5(手动刷新);

原创文章 8 获赞 6 访问量 7528

猜你喜欢

转载自blog.csdn.net/qq_22938623/article/details/77655057
今日推荐