加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – WebApproot在Spring

发布时间:2020-12-16 08:08:52 所属栏目:百科 来源:网络整理
导读:我得到这个错误消息 [ SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener java.lang.IllegalStateException: Web app root system property already set to different
我得到这个错误消息

[ SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.util.Log4jConfigListener
java.lang.IllegalStateException: Web app root system property already set to different value: ‘webapp.root’ = [C:UsersjaanlaiDocumentsNetBeansProjectsabsSovellusbuildweb] instead of [C:UsersAdministratorDocumentsNetBeansProjectskeycard2buildweb] – Choose unique values for the ‘webAppRootKey’ context-param in your web.xml files!

这很奇怪,因为我的文件中没有定义任何webAppRootKey。它是什么?

webAppRootKey是Spring在几个地方使用的上下文参数。在这种情况下,它正由Log4jWebConfigurer使用。它暴露webapp根作为系统属性,可以在log4j配置文件中使用,像这样:
log4j.appender.testfile.File=${webapp.root}/WEB-INF/testlog.log

如果由于某种原因想要找??到相对于您的webapp根目录的日志,您将使用这个。

你遇到的问题是一些容器(特别是Tomcat)不维护系统属性的per-webapp映射。当您不指定webAppRootKey时,Spring默认将其设置为webapp.root。由于您在同一个容器中运行两个应用程序,因此您尝试启动的第二个应用程序会看到webAppRootKey已设置(通过默认设置),并引发错误。否则,webAppRootKey将设置不正确,您可以结束与来自另一个webapp中的一个webapp的日志。

您可以使用web.xml中的上下文参数指定不同的webAppRootKey,如下所示:

<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>webapp.root.one</param-value>
</context-param>

log4j.appender.testfile.File=${webapp.root.one}/WEB-INF/testlog.log

在你的log4j。这应该照顾冲突。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读