java web error:Choose unique values for the 'webAppRootKey'

描述:

tomcat部署多个web工程的时候抛异常:

写道
java web error:Choose unique values for the 'webAppRootKey' context-param in your web.xml files

原因:

写道
1.Log4jWebConfigurer在初始化日志的时候调用WebUtils.setWebAppRootSystemProperty
2.setWebAppRootSystemProperty的时候
String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);
String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY);
String oldValue = System.getProperty(key);
if (oldValue != null && !StringUtils.pathEquals(oldValue, root)) {
throw new IllegalStateException(
"Web app root system property already set to different value: '" +
key + "' = [" + oldValue + "] instead of [" + root + "] - " +
"Choose unique values for the 'webAppRootKey' context-param in your web.xml files!");
}
key重复报错了

解决方式:

web.xml中设置不同的

public static final String WEB_APP_ROOT_KEY_PARAM = "webAppRootKey";

如:

<context-param>
	<param-name>webAppRootKey</param-name>
	<param-value>www.linkrmb.com</param-value>
	<description>领客网目标:扫遍京东、天猫折扣最低的商品!</description>
</context-param>

尽可能的用域名或者host等唯一性比较强的做key

其默认值为:

public static final String DEFAULT_WEB_APP_ROOT_KEY = "webapp.root";

你可能感兴趣的:(Java Web)