【问题标题】:How to set context.xml in tomcat run configuration in Idea如何在Idea中的tomcat运行配置中设置context.xml
【发布时间】:2018-02-10 12:44:12
【问题描述】:

我正在尝试为本地开发部署一个war 文件,并且我想修改tomcat 的context.xml 以通过jndi 提供数据源。这在使用 tomcat7-maven-plugin 时有效:

        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <contextFile>../../tomcat-test-context.xml</contextFile>
            </configuration>
        </plugin>

问题是,tomcat7-maven-plugin 不适用于我在项目中使用的覆盖,所以我必须使用另一种方法。我可以在 intellij idea 中部署战争工件,但我没有看到任何选项来指定 contextFile ,就像在 tomcat7-maven-plugin 中一样。在 intellij idea tomcat 配置中是否有一些选项可以做类似的事情?

当然我可以修改catalina home下的context.xml,但是我希望每个项目都配置它,不想有很多tomcat。

该应用程序在生产中部署在 weblogic 上,我仅在本地使用 tomcat 进行测试。

【问题讨论】:

    标签: intellij-idea tomcat7


    【解决方案1】:

    不确定这是否会有所帮助,但我是这样做的:

    1. 在 IntelliJ 中,在 webapp 下,我创建了 META-INF 文件夹 -> context.xml 并定义了我的资源
    2. 然后我必须在我的 Java 代码(JDNI 查找)中查找它,如此处接受的答案所述:Tomcat and JDBC connection pooling

    【讨论】:

      猜你喜欢
      • 2021-05-14
      • 2016-10-28
      • 2012-04-07
      • 1970-01-01
      • 1970-01-01
      • 2013-11-19
      • 2017-07-25
      • 2019-06-07
      相关资源
      最近更新 更多