运行Eclipse Debugger时使用Maven配置文件

时间:2013-06-23 14:31:41

标签: eclipse maven m2eclipse

在我的m2eclipse项目中,我有一个 context.xml 文件,它指定了我的数据库连接设置(例如,驱动程序,URL,用户名,密码)。我没有直接在 context.xml 文件中指定这些属性的值,而是在项目的 pom.xml 文件中创建了一个Maven配置文件,该文件定义了这些属性的值。属性。例如:

. . .
<properties>
    <database.driverClassName>com.mysql.jdbc.Driver</database.driverClassName>
    <database.user>admin</database.user>
    . . .
</properties>
. . .

并在我的 context.xml 文件中看到

. . .
driverClassName="${database.driverClassName}"
username="${database.user}"
. . .

我想知道的是在Eclipse中运行调试器时如何让我的配置文件填充 context.xml 文件。现在我不能这样做,只需运行Eclipse的调试器,并将context.xml硬编码为值(即,我不使用Maven配置文件)。在运行Eclipse调试器时,可以使用Maven配置文件轻松完成吗?也许可以使用m2eclipse Eclipse插件完成?我在Tomcat服务器上运行它。

2 个答案:

答案 0 :(得分:0)

您是否尝试过使用m2e-wtp

观看此截屏视频,了解网络资源过滤如何与m2e-wtp中的个人资料配合使用:http://goo.gl/RysBw

请注意profile management UI来自JBoss Tools,可以单独安装。

答案 1 :(得分:0)

您可以使用resource filtering执行此操作。它在编译时完成,不仅限于调试。如果我是对的你只需要添加:

  ...
  <resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
  </resource>
  ...