gpt4 book ai didi

java - 如何用maven切换conf tomcat

转载 作者:行者123 更新时间:2023-11-28 22:57:00 24 4
gpt4 key购买 nike

我已经在使用 Maven 的 Java 高环境项目中添加集成测试。为此,我必须添加一个新的测试数据库(数据库的极简真实副本)。在那之前一切都很好。针对问题是我的文件中有两个不同的配置:

\web\target\tomcat\conf\context.xml

所以我总是在评论中放一个资源。资源示例:

<Resource
auth = "jdbc / soarepo"
driverClassName = "oracle.jdbc.driver.OracleDriver"
logAbandoned = "true"
maxActive = "32"
maxIdle = "32"
maxWait = "10000"
name = "jdbc / soarepo"
password = "..."
username = "..."
removeAbandoned = "true"
removeAbandonedTimeout = "60"
type = "javax.sql.DataSource"
url = "jdbc: oracle: thin: @ ..."
/>

问:如何使用 Maven 从一个资源切换到另一个资源?

I already use a profile for integration tests. So I have to change what resources when the profile is called ?

最佳答案

如果您使用的是 Maven Tomcat Plugin要运行您的 Web 应用程序,您可以使用 contextFile 指定自定义的依赖于服务器的部署描述符 context.xml 的路径。属性:

<profiles>
<profile>
<id>integration-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<contextFile>/path/to/context/file</contextFile>
</configuration>
</plugin>
</plugins>
</build>
</profile>

.. Other profiles ..

</profiles>

关于java - 如何用maven切换conf tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24627341/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com