您好,登錄后才能下訂單哦!
在tomcat里配置多個實例時,不能使用默認的webAppRootKey,需要明確在web.xml里配置webAppRootKey值,否則在啟動時會報錯,報錯如下示
嚴重: Exception sending context initialized event to listener instance of class ch.qos.logback.ext.spring.web.LogbackConfigListener java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [C:\apache-tomcat-8.0.32\webapps\weblearn\] instead of [C:\apache-tomcat-8.0.32\webapps\weblearn3\] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files! at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:162) at ch.qos.logback.ext.spring.web.WebLogbackConfigurer.initLogging(Unknown Source) at ch.qos.logback.ext.spring.web.LogbackConfigListener.contextInitialized(Unknown Source) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:585) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1794) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
所以在web.xml里配置了webAppRootKey,因為之前配置了logback的配置,于是將webAppRootKey的配置與logback的配置放在一起,如下示.
<context-param> <param-name>logbackConfigLocation</param-name> <param-value>/WEB-INF/config/logback3.xml</param-value> <param-name>webAppRootKey</param-name> <param-value>weblearn3.root</param-value> </context-param>
重啟服務器后發現沒有上面的報錯了,但是服務器日志卻不生成到文件里了,于是判斷context-param只能放一對param-name和param-value,最后修改如下
<context-param> <param-name>webAppRootKey</param-name> <param-value>weblearn3.root</param-value> </context-param> <context-param> <param-name>logbackConfigLocation</param-name> <param-value>/WEB-INF/config/logback3.xml</param-value> </context-param>
問題解決
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。