【问题标题】:Placeholders in properties file are not replaced in target by maven属性文件中的占位符不会在目标中被 maven 替换
【发布时间】:2017-09-08 00:47:46
【问题描述】:

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

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

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

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>

但是没有用。

欢迎所有建议。

最好的问候。

【问题讨论】:

    标签: java maven tomcat jdbc


    【解决方案1】:

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

    设置

    <filtering>true</filtering>
    

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

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

    【讨论】:

      猜你喜欢
      • 2013-11-15
      • 2019-06-04
      • 1970-01-01
      • 1970-01-01
      • 2017-12-17
      • 2011-01-13
      • 1970-01-01
      • 1970-01-01
      • 2021-04-03
      相关资源
      最近更新 更多