gpt4 book ai didi

java - maven 不会在目标中替换属性文件中的占位符

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

我有一个包含以下内容的 filter.properties 文件:

database.driver= mydatabase
database.url= myURL
database.user=usr
database.password=pwd
database.initialsize=3
database.maxactive=5

我的 openejb.xml 文件中的 Resource 标签中也有这个:

JdbcDriver ${database.driver}
JdbcUrl ${database.url}
UserName ${database.user}
Password ${database.password}

但是当我使用 maven 执行 tomee:run 时,我会遇到大量此类错误:

Unable to resolve class ${database.driver}

Caused by: java.lang.ClassNotFoundException: ${database.driver}

我试图通过在我的 pom.xml 中添加来解决这个问题:

<properties>
<myDatabase.driver>${database.driver}</myDatabase.driver>
</properties>

但是没有用。

欢迎所有建议。

最好的问候。

最佳答案

https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

设置

<filtering>true</filtering>

这假设一切都是资源,类路径上的文件。

或者在 Tomcat 中的应用程序之外创建这样的数据源。

关于java - maven 不会在目标中替换属性文件中的占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43366129/

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