【发布时间】:2014-03-04 08:47:58
【问题描述】:
我有一个带有两个不同数据库配置文件的 Maven 模块。
<profile>
<id>db-localhost-oracle</id>
<dependencies>
<dependency>
<groupId>ojdbc6</groupId>
<artifactId>ojdbc6</artifactId>
</dependency>
</dependencies>
<properties>
<db.driver>oracle.jdbc.driver.OracleDriver</db.driver>
<db.dialect>no.jbv.sergej.util.FixedOracle10gDialect</db.dialect>
<db.url>jdbc:oracle:thin:@//localhost:1521/xe</db.url>
<db.hbm2ddl>update</db.hbm2ddl>
</properties>
</profile>
<profile>
<id>db-localhost-mysql</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
<properties>
<db.driver>com.mysql.jdbc.Driver</db.driver>
<db.dialect>org.hibernate.dialect.MySQL5Dialect</db.dialect>
<db.url>jdbc:mysql://localhost/${mysql.schema}</db.url>
<db.hbm2ddl>update</db.hbm2ddl>
</properties>
</profile>
当使用“db-localhost-mysql”运行 maven install 时,它在 lib 目录中包含“mysql-connector-java”jar 文件。现在我使用“db-localhost-oracle”进行全新安装,它在 lib 目录中包含“mysql-connector-java”和“ojdbc6”jar。
如果我使用一个配置文件构建,maven 会自动删除其他配置文件的 jar,我该如何做到这一点?
【问题讨论】: