繁体   English   中英

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

[英]Placeholders in properties file are not replaced in target by maven

我有一个 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}

但是当我做一个 tomee:run with maven 时,我得到了很多这种类型的错误:

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 中的应用程序之外创建这样的数据源。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM