首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Hibernate3 Maven插件配置错误?

Hibernate3 Maven插件配置错误?
EN

Stack Overflow用户
提问于 2011-07-04 22:26:52
回答 1查看 2.6K关注 0票数 1

当我第一次建立我的项目时,我已经知道如果它不停止做两次事情,现在是时候了,我会疯掉的。我还没有找到解决办法,或者我只是不知道如何去寻找这个问题。

我有一些hbm.xml文件在我的构建过程中被处理。首先,您可以看看我的pom.xml部分,它应该能做到这一点。

代码语言:javascript
复制
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <id>generate-xml-files</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>hbm2cfgxml</goal>
                    </goals>
                </execution>
                <execution>
                    <id>generate-entities</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>hbm2java</goal>
                    </goals>
                </execution>
                <execution>
                    <id>generate-schema</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>hbm2ddl</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <components>
                    <component>
                        <name>hbm2cfgxml</name>
                        <implementation>configuration</implementation>
                        <outputDirectory>target/classes</outputDirectory>
                    </component>
                    <component>
                        <name>hbm2java</name>
                        <implementation>configuration</implementation>
                        <outputDirectory>src/main/java</outputDirectory>
                    </component>
                    <component>
                        <name>hbm2ddl</name>
                        <implementation>configuration</implementation>
                        <outputDirectory>target/classes</outputDirectory>
                    </component>
                </components>
                <componentProperties>
                    <jdk5>true</jdk5>
                    <packagename>com.blazebit.web.cms.core.model</packagename>
                    <propertyfile>src/main/resources/database.properties</propertyfile>
                    <configurationfile>target/classes/hibernate.cfg.xml</configurationfile>
                    <!-- Tells the plugin to send the output to a file -->
                    <outputfilename>schema.sql</outputfilename>
                    <!-- Pretty Format SQL Code -->
                    <format>true</format>
                    <!-- Do not create tables automatically - other plug-ins will handle that -->
                    <export>false</export>
                    <!-- Do not print the DDL to the console -->
                    <console>false</console>
                </componentProperties>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>5.0.8</version>
                </dependency>
                <dependency>
                    <groupId>cglib</groupId>
                    <artifactId>cglib-nodep</artifactId>
                    <version>2.1_3</version>
                </dependency>
            </dependencies>  
        </plugin>
        <plugin>
            <groupId>com.blazebit</groupId>
            <artifactId>HibernateCfgBuilder</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <id>HibernateCfgBuilder</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>HibernateCfgBuilder</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <hbmXmlFilesDir>src/main/resources/com/blazebit/web/cms/core/model/</hbmXmlFilesDir>
                <configFile>target/classes/hibernate.cfg.xml</configFile>
                <packageName>com.blazebit.web.cms.core.model</packageName>
            </configuration>
        </plugin>

现在让我解释一下这一切应该做些什么。

  • 第一件事是hbm2cfg,我认为它应该创建一个hibernate.cfg.xml
  • 第二步是我自己的插件,它将hbm.xml文件的路径添加到hibernate.cfg.xml(找不到解决这个问题的其他解决方案)。
  • 第三步是hbm2java,它应该将java文件生成到我的源目录中。
  • 最后,hbm2ddl应该在类路径中为该模型创建schema.sql

听起来很简单?它甚至可以工作,但它似乎做了两次甚至更多的事情,现在我的构建大约需要2分钟,这让我很烦恼:/有人能给我一个提示,说明我可以改变什么来使这个步骤工作吗?

EN

回答 1

Stack Overflow用户

发布于 2011-07-06 05:54:29

我认为它将某些目标称为两次,因为一些hibernate3-maven-plugin目标是“调用生命周期阶段的执行--在执行自身之前生成资源”,如文档中所述。。我也面临着这个问题,如果它真的惹恼了您,那么我建议尝试将它们称为来自maven-antrun-plugin的Ant目标(但我不测试这个)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6576533

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档