单独的web.xml用于开发和生产 [英] Separate web.xml for development and production
问题描述
通常我部署新的应用程序版本如下:
< $ / $>
问题是我必须在导出之前手动取消web.xml中的安全约束。
你如何解决这个问题?
我还在一些文章中认为web.xml很少更改。但是如果web.xml在每次更新时导出为WAR,那么web.xml如何才能更改?
提前感谢!
如果在开发过程中不能使用相同的 web.xml
,我将自动化构建过程,使用两个 web.xml
,并根据Brian建议的目标环境在构建时捆绑正确。但是,而不是Ant,我会选择Maven,因为它将需要更少的工作IMHO,它有一个内置的功能,称为个人资料,这是完美的管理环境特定的东西,如这里。换句话说,我会将构建放在Maven 2下,并使用包含特定maven-war-plugin配置的生产配置文件构建包含具有所需安全限制的 web.xml
的WAR。另一个选择是合并开发 web.xml
(货物可以做到这一点)来增加安全约束,但这已经是一个更先进的解决方案(要复杂一点)。
My web.xml is different in devel and production environments. For example in development environment there is no need in security constraints.
Typically I deploy new application version as follows:
- Export Eclipse project to WAR.
- Upload WAR to the server.
- Redeploy.
The problem is that I have to manually uncomment security constraints in web.xml before exporting.
How do you solve this problem?
I also met an opinion in some articles that "web.xml is rarely changed". But how can web.xml not change if it is exported to WAR on every update?
Thanks in advance!
If you can't use the same web.xml
during development, I would automate the build process, use two web.xml
and bundle the "right" one at build time depending on the targeted environment as Brian suggested. But, instead of Ant, I'd choose Maven because it will require less work IMHO and it has a built-in feature called profiles that is perfect to manage environment specific stuff like here.
In other words, I'd put the build under Maven 2 and use a production profile containing a specific maven-war-plugin configuration to build a WAR containing a web.xml
having the required security constraints. Another option would be to merge the development web.xml
(cargo can do that) to add the security-constraints but this is already a bit more "advanced" solution (a bit more complex to put in place).
这篇关于单独的web.xml用于开发和生产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!