我有两个数据库,我想生成hbm2java。
<project>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version> 2.2</version>
<executions>
<execution>
<id>db1</id>
<configuration>
<components>
<component>
<name>hbm2java</name>
...
</component>
</components>
<componentProperties>
...
<configurationfile>.../hibernate1.cfg.xml</configurationfile>
</componentProperties>
</execution>
<execution>
<id>db2</id>
<configuration>
<components>
<component>
<name>hbm2java</name>
...
</component>
</components>
<componentProperties>
...
<configurationfile>.../hibernate2.cfg.xml</configurationfile>
</componentProperties>
</execution>
</executions>
...
</plugin>
...
</plugins>
...
</project>
好的,如果我运行mvn hibernate3:hbm2java
,那么它就不会执行!
这是日志:
[INFO] >>> hibernate3-maven-plugin:2.2:hbm2java (default-cli) @ XXXXXXXXXXXXX >>>
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ XXXXXXXXXXXXX ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] <<< hibernate3-maven-plugin:2.2:hbm2java (default-cli) @ XXXXXXXXXXXXX <<<
[INFO]
[INFO] --- hibernate3-maven-plugin:2.2:hbm2java (default-cli) @ XXXXXXXXXXXXX ---
[INFO] using configuration task.
11:07:29,370 INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
11:07:29,376 INFO org.hibernate.cfg.Environment - hibernate.properties not found
11:07:29,381 INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
11:07:29,387 INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
[INFO] No hibernate configuration file loaded.
[INFO] No hibernate properties file loaded.
11:07:29,464 INFO org.hibernate.tool.Version - Hibernate Tools 3.2.4.GA
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
有什么想法吗?
答案 0 :(得分:1)
这些执行只与生命周期有关,这意味着你必须打电话:
mvn process-resources
而不是简单地调用插件的目标。或者是后期阶段:
mvn compile
答案 1 :(得分:1)
好吧,我无法通过生命周期分离hbm2java的执行。
我有一个使用自定义配置文件“generate”的解决方案:
<project>
<profiles>
<profile>
<id>generate</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>db1</id>
<configuration>
<components>
<component>
<name>hbm2java</name>
...
</component>
</components>
<componentProperties>
...
<configurationfile>.../hibernate1.cfg.xml</configurationfile>
</componentProperties>
</execution>
<execution>
<id>db2</id>
<configuration>
<components>
<component>
<name>hbm2java</name>
...
</component>
</components>
<componentProperties>
...
<configurationfile>.../hibernate2.cfg.xml</configurationfile>
</componentProperties>
</execution>
</executions>
...
</plugin>
...
</plugins>
</build>
</profile>
</profiles>
...
</project>
现在我需要执行3种不同的执行:
mvn install -Dmaven.test.skip=true
编译逆向工程策略mvn compile -P generate
生成类mvn test
测试单元测试