Maven不会重写JUnit / Mockito上下文中的属性.xml



我正在用Spring和Mockito运行一个JUnit测试,我有一个可注入的bean,配置如下:

<bean name="roleDefault" id="roleDefault" class="java.lang.String">
  <constructor-arg>
    <value>${database.rule}</value>
  </constructor-arg>
</bean>

我的pom.xml在一个id为"desenvolvimento"的配置文件中有这样的配置:

<database.rule>SET ROLE RO_APP IDENTIFIED BY WEBAPP</database.rule>

问题是:在Eclipse中或使用mvn test运行所有测试都不会计算${database.rule}的值,导致以下错误:

Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "${database.rule}" [42000-165]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:169)
    at org.h2.message.DbException.get(DbException.java:146)
    at org.h2.message.DbException.getSyntaxError(DbException.java:181)
    at org.h2.jdbc.JdbcConnection.checkRunOver(JdbcConnection.java:1318)
    at org.h2.jdbc.JdbcConnection.translateSQL(JdbcConnection.java:1271)
    at org.h2.jdbc.JdbcConnection.translateSQL(JdbcConnection.java:1187)
    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:265)
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$1.doPrepare(StatementPreparerImpl.java:98)
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182)
    ... 75 more

为什么maven不重写database.rule的值?

确保XML配置文件的位置包含在pom.XML的资源过滤器中。

<resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/*.xml</include> </includes> </resource>

相关内容

  • 没有找到相关文章

最新更新