使用context.xml将Java参数传递给Tomcat WebApp

时间:2015-08-22 14:44:36

标签: tomcat configuration spring-boot spring-cloud context.xml

我有一个名为“lab-4-eureka-server”的应用程序,我已经制作了一个war文件。我正在将此应用程序部署到我的独立tomcat中。部署应用程序时,由于未指定spring.profiles.active,因此webapp以默认默认值启动。在线阅读后,我发现如果我在base / conf / Catalina / localhost文件夹中创建了一个context.xml,我可以将特定参数传递给我的webapp。 我在localhost文件夹中创建了一个“lab-4-eureka-server.xml”,其中包含以下内容(这只是一个黑暗的镜头,以显示我正在尝试做的事情)。

<?xml version="1.0" encoding="UTF-8"?>
<!-- Context configuration file for my web application -->
<Context>
<Resource name="profile" type="spring.profiles.active" value="primary" />
</Context>

我可以看到,当tomcat部署我的webapp时,它会尝试使用此文件,但以下情况除外: Tomcat Exception Pic

我的context.xml应该怎么说才能加载配置文件?我已经读过我可以编辑一些catalina.sh或其他文件,但是(根据我的理解),这些配置会将相同的java参数发送到所有已部署的webapps。我要去context.xml路由,因为我打算将不同的java参数发送到不同的webapps

(注意:我知道spring boot可以启动它自己的tomcat服务器。我将把多个webapps部署到1个tomcat服务器中,这就是我需要它的原因)

0 个答案:

没有答案
相关问题