我一直在尝试使用 maven-war-plugin 来过滤具有配置文件定义的属性的 web.xml,我让它在部署时工作,但在我的本地服务器 (Apache Tomcat 7.0.65) 上不起作用。
我在 web.xml 上有这个
<env-entry>
<env-entry-name>variableName</env-entry-name>
<env-entry-value>${property.variableName}</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
这在 pom.xml 上
<property.variableName>This is a variable</property.variableName>
还有代码:
InitialContext init = new InitialContext();
String variable = (String)init.lookup("java:comp/env/variableName");
事实是...在生成的 web.xml (target/...web.xml) 上,变量被新值过滤,但是当我尝试打印“变量”值时部署在本地是日志 ${property.variableName}
知道如何解决这个问题吗?
提前致谢和问候,
最佳答案
我终于成功了。似乎与无法识别某些文件夹或类似内容的部署程序集有关。
下面的帖子帮助我找到了它: Maven: how to fill a variable in web.xml file
关于maven-war-plugin 不过滤本地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35268703/