hibernate5-ddl-maven-plugin在类路径

时间:2017-03-20 17:27:43

标签: hibernate spring-data-jpa maven-plugin ddl

当我尝试使用maven插件生成DDL时

Maven home: /home/workspace/hscli/EMBEDDED
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
...
<plugin>
    <groupId>de.jpdigital</groupId>
    <artifactId>hibernate5-ddl-maven-plugin</artifactId>
        <version>1.0.1-hibernate-5.1.2.Final</version>
    <configuration>
        <dialects>
            <param>oracle10g</param>
        </dialects>
        <packages>
            <param>hscli.entities.tables</param>
        </packages>
        <outputDirectory>${basedir}/sql/ddl</outputDirectory>
        <persistenceXml>${basedir}/sql/persistence_for_generation_purpose.xml</persistenceXml>
        <createDropStatements>true</createDropStatements>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>gen-ddl</goal>
            </goals>
            <phase>process-classes</phase>
        </execution>
    </executions>
</plugin>

定期阅读配置

[DEBUG] Configuring mojo de.jpdigital:hibernate5-ddl-maven-plugin:1.0.1-hibernate-5.1.2.Final:gen-ddl from plugin realm ClassRealm[plugin>de.jpdigital:hibernate5-ddl-maven-plugin:1.0.1-hibernate-5.1.2.Final, parent: sun.misc.Launcher$AppClassLoader@409a44d6]
[DEBUG] Configuring mojo 'de.jpdigital:hibernate5-ddl-maven-plugin:1.0.1-hibernate-5.1.2.Final:gen-ddl' with basic configurator -->
[DEBUG]   (s) createDropStatements = true
[DEBUG]   (s) dialects = [oracle10g]
[DEBUG]   (s) outputDirectory = /home/workspace/hscli/sql/ddl
[DEBUG]   (s) packages = [hscli.entities.tables]
[DEBUG]   (s) persistenceXml = /home/workspace/hscli/sql/persistence_for_generation_purpose.xml
[DEBUG]   (f) project = MavenProject: hscli:hscli:0.0.1-SNAPSHOT @ /home/workspace/hscli/pom.xml
[DEBUG] -- end configuration --

并将元素添加到classpath

[INFO] Generating DDL SQL files in /home/workspace/hscli/sql/ddl.
[INFO] Adding classpath elemement '/home/workspace/hscli/target/classes'...
...
[INFO] Classpath URLs:
[INFO]  file:/home/workspace/hscli/target/classes/

但似乎找不到任何实体

[INFO] Found 0 entities.

怎么可能?

1 个答案:

答案 0 :(得分:0)

我解决了更改che pom.xml文件的问题

<plugin>
    <groupId>de.jpdigital</groupId>
    <artifactId>hibernate52-ddl-maven-plugin</artifactId>
    <version>2.1.0</version>
    <configuration>
        <dialects>
            <param>oracle10g</param>
        </dialects>
        <outputDirectory>${basedir}/sql/ddl</outputDirectory>
        <persistenceXml>${basedir}/sql/persistence_for_generation_purpose.xml</persistenceXml>
        <createDropStatements>true</createDropStatements>
        <omitDialectFromFileName>true</omitDialectFromFileName>
        <outputFileNamePrefix>000-</outputFileNamePrefix>
        <outputFileNameSuffix>createDataBase</outputFileNameSuffix>
        <packages>
            <param>hsm.entities.tables</param>
        </packages>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>gen-ddl</goal>
            </goals>
            <phase>process-classes</phase>
        </execution>
    </executions>
</plugin>