Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
自定义hibernate工具导出器_Hibernate_Maven_Hibernate Tools_Hibernate3 Maven Plugin - Fatal编程技术网

自定义hibernate工具导出器

自定义hibernate工具导出器,hibernate,maven,hibernate-tools,hibernate3-maven-plugin,Hibernate,Maven,Hibernate Tools,Hibernate3 Maven Plugin,我使用maven插件生成pojo和dao: <groupId>org.codehaus.mojo</groupId> <artifactId>hibernate3-maven-plugin</artifactId> <version>2.2</version> <executions> <execution> <phase>generate-sources</

我使用maven插件生成pojo和dao:

<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
    <execution>
        <phase>generate-sources</phase>
        <goals>
            <goal>hbm2java</goal>
            <goal>hbm2dao</goal> 
            <goal>hbm2ddl</goal>
        </goals>
    </execution>
</executions>
<configuration>
    <components>
        <component>
            <name>hbm2java</name>
            <implementation>configuration</implementation>
            <outputDirectory>src/main/java</outputDirectory>
        </component>
        <component>
            <name>hbm2dao</name>
            <implementation>configuration</implementation>
            <outputDirectory>src/main/java</outputDirectory>
        </component>
        <component>
            <name>hbm2ddl</name>
            <implementation>configuration</implementation>
            <outputDirectory>src/main/resources/sql</outputDirectory>
        </component>
    </components>
    <componentProperties>
        <jdk5>true</jdk5>
        <format>true</format>
        <configurationfile>src/main/resources/hibernate/hibernate.cfg.xml</configurationfile>

        <drop>true</drop>
        <create>true</create>
        <outputfilename>init.sql</outputfilename>
        <templatepath>src/main/resources/templateftl</templatepath>

    </componentProperties>
</configuration>
我发现它非常难看,我想把pojo和dao放在不同的包装中,并且不要用“家”作为dao的后缀,只要用“dao”

你知道有没有办法提供一个自定义的导出器实现,或者在插件中配置一些东西来实现这一点


谢谢

最后,我使用JD gui反编译并读取了插件的代码,我成功地运行了2次插件,每次使用不同的模板以hbmtemplate为目标:一个用于实体,一个用于dao

我发现可以通过在exporterclass中指定自定义导出器来使用它。 maven插件缺少一些xsd之王

    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>2.2</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <id>genpojo</id>
            <goals>
                <goal>hbmtemplate</goal> 
                <goal>hbm2ddl</goal>
            </goals>
            <configuration>
            <components>
                <component>
                    <name>hbmtemplate</name>
                    <implementation>configuration</implementation>
                    <outputDirectory>src/main/java</outputDirectory>
                </component>                        
                <component>
                    <name>hbm2ddl</name>
                    <implementation>configuration</implementation>
                    <outputDirectory>src/main/resources/sql</outputDirectory>
                </component>
            </components>
            <componentProperties>
                <jdk5>true</jdk5>
                <format>true</format>
                <configurationfile>src/main/resources/hibernate/hibernate.cfg.xml</configurationfile>
                <drop>true</drop>
                <create>true</create>
                <outputfilename>init.sql</outputfilename>
                <templatepath>src/main/resources/templateftl</templatepath>
                <filepattern>{package-name}/pojogen/{class-name}.java</filepattern>
                <template>pojo/Pojo.ftl</template>
            </componentProperties>
        </configuration>
        </execution>
        <execution>
            <phase>generate-sources</phase>
            <id>gendao</id>
            <goals>                         
                <goal>hbmtemplate</goal>
            </goals>
            <configuration>
            <components>                        
                 <component>
                    <name>hbmtemplate</name>
                    <implementation>configuration</implementation>
                    <outputDirectory>src/main/java</outputDirectory>
                </component>
            </components>
            <componentProperties>
                <jdk5>true</jdk5>
                <format>true</format>
                <configurationfile>src/main/resources/hibernate/hibernate.cfg.xml</configurationfile>
                <drop>true</drop>
                <create>true</create>
                <templatepath>src/main/resources/templateftl</templatepath>
                <!--  <exporterclass>com.db.exporter.MyDAOExporter</exporterclass>-->
                <filepattern>{package-name}/daogen/{class-name}Dao.java</filepattern>
                <template>dao/daohome.ftl</template>
            </componentProperties>
        </configuration>
        </execution>
    </executions>

</plugin>

org.codehaus.mojo
hibernate3 maven插件
2.2
生成源
根波乔
hbmtemplate
hbm2ddl
hbmtemplate
配置
src/main/java
hbm2ddl
配置
src/main/resources/sql
符合事实的
符合事实的
src/main/resources/hibernate/hibernate.cfg.xml
符合事实的
符合事实的
init.sql
src/main/resources/templateftl
{package name}/pojogen/{class name}.java
pojo/pojo.ftl
生成源
根道
hbmtemplate
hbmtemplate
配置
src/main/java
符合事实的
符合事实的
src/main/resources/hibernate/hibernate.cfg.xml
符合事实的
符合事实的
src/main/resources/templateftl
{package name}/daogen/{class name}Dao.java
dao/daohome.ftl
    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>2.2</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <id>genpojo</id>
            <goals>
                <goal>hbmtemplate</goal> 
                <goal>hbm2ddl</goal>
            </goals>
            <configuration>
            <components>
                <component>
                    <name>hbmtemplate</name>
                    <implementation>configuration</implementation>
                    <outputDirectory>src/main/java</outputDirectory>
                </component>                        
                <component>
                    <name>hbm2ddl</name>
                    <implementation>configuration</implementation>
                    <outputDirectory>src/main/resources/sql</outputDirectory>
                </component>
            </components>
            <componentProperties>
                <jdk5>true</jdk5>
                <format>true</format>
                <configurationfile>src/main/resources/hibernate/hibernate.cfg.xml</configurationfile>
                <drop>true</drop>
                <create>true</create>
                <outputfilename>init.sql</outputfilename>
                <templatepath>src/main/resources/templateftl</templatepath>
                <filepattern>{package-name}/pojogen/{class-name}.java</filepattern>
                <template>pojo/Pojo.ftl</template>
            </componentProperties>
        </configuration>
        </execution>
        <execution>
            <phase>generate-sources</phase>
            <id>gendao</id>
            <goals>                         
                <goal>hbmtemplate</goal>
            </goals>
            <configuration>
            <components>                        
                 <component>
                    <name>hbmtemplate</name>
                    <implementation>configuration</implementation>
                    <outputDirectory>src/main/java</outputDirectory>
                </component>
            </components>
            <componentProperties>
                <jdk5>true</jdk5>
                <format>true</format>
                <configurationfile>src/main/resources/hibernate/hibernate.cfg.xml</configurationfile>
                <drop>true</drop>
                <create>true</create>
                <templatepath>src/main/resources/templateftl</templatepath>
                <!--  <exporterclass>com.db.exporter.MyDAOExporter</exporterclass>-->
                <filepattern>{package-name}/daogen/{class-name}Dao.java</filepattern>
                <template>dao/daohome.ftl</template>
            </componentProperties>
        </configuration>
        </execution>
    </executions>

</plugin>