使用 Elastic Beanstalk 时保留 WAR 名称
Keeping WAR name when using Elastic Beanstalk
当我使用 Elastic Beanstalk 部署我的 app.war
文件时,它部署在 ROOT 上下文中,因此当我需要它在 [=] 可用时,我可以在 http://any-domain/
访问它13=].
我在 EC2 实例上使用 tomcat 8。我知道这个问题可能与 ebextensions and/or context.xml config.
有关
终于解决了
我将一个名为 server-update.config
的文件添加到位于 .war
文件根目录的 .ebextensions
目录中。文件内容如下所示:
container_commands:
replace-config:
command: cp .ebextensions/server.xml /etc/tomcat8/server.xml
关于 ebextensions 的更多信息:https://aws.amazon.com/blogs/aws/customize-elastic-beanstalk-using-configuration-files/
关于 server.xml
,我将 server.xml 放在 /etc/tomcat8
并在 部分中添加了以下部分.
<Context path="app" docBase="ROOT"/>
感谢这个回答:
此行为是设计使然:"In a single WAR source bundle, the application always runs at the root path."
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-platform.html
如果您想覆盖此行为,最简单的方法是创建一个只有两个 war 文件的多 war 包(基本上只是一个包含 war秒)。 zip 中 war 的名称将决定路径(很确定这只适用于一层深度),在这种情况下,您可以将其命名为 "app.war",并且还必须包含一个 [=17] =] 可以为空。
当我使用 Elastic Beanstalk 部署我的 app.war
文件时,它部署在 ROOT 上下文中,因此当我需要它在 [=] 可用时,我可以在 http://any-domain/
访问它13=].
我在 EC2 实例上使用 tomcat 8。我知道这个问题可能与 ebextensions and/or context.xml config.
有关终于解决了
我将一个名为 server-update.config
的文件添加到位于 .war
文件根目录的 .ebextensions
目录中。文件内容如下所示:
container_commands:
replace-config:
command: cp .ebextensions/server.xml /etc/tomcat8/server.xml
关于 ebextensions 的更多信息:https://aws.amazon.com/blogs/aws/customize-elastic-beanstalk-using-configuration-files/
关于 server.xml
,我将 server.xml 放在 /etc/tomcat8
并在
<Context path="app" docBase="ROOT"/>
感谢这个回答:
此行为是设计使然:"In a single WAR source bundle, the application always runs at the root path." http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-platform.html
如果您想覆盖此行为,最简单的方法是创建一个只有两个 war 文件的多 war 包(基本上只是一个包含 war秒)。 zip 中 war 的名称将决定路径(很确定这只适用于一层深度),在这种情况下,您可以将其命名为 "app.war",并且还必须包含一个 [=17] =] 可以为空。