2012-02-14 10 views
12

का उपयोग कर hbm2ddl उत्पन्न करने में असमर्थ मैंने hibernate3-maven-plugin के एक नए संस्करण में अद्यतन किया है। मुझे नीचे उल्लिखित प्लगइन का उपयोग करने का प्रयास करने में निम्न त्रुटि मिलती है।hibernate3-maven-plugin-3.0

इस मुद्दे को हल करने में किसी भी संकेतक की सराहना करेंगे।

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>hibernate3-maven-plugin</artifactId> 
    <version>3.0</version> 

    <executions> 
     <execution> 
      <id>create sql schema</id> 
      <phase>process-test-resources</phase> 
      <goals> 
       <goal>hbm2ddl</goal> 
      </goals> 
      <configuration> 
       <componentProperties> 
        <persistenceunit>${app.module}</persistenceunit> 
        <drop>false</drop> 
        <create>true</create> 
        <outputfilename>${app.sql}-create.sql</outputfilename> 
        <skip>${db.schema.gen.skip}</skip> 
       </componentProperties> 
      </configuration> 
     </execution> 

     <execution> 
      <id>drop sql schema</id> 
      <phase>process-test-resources</phase> 
      <goals> 
       <goal>hbm2ddl</goal> 
      </goals> 
      <configuration> 
       <componentProperties> 
        <persistenceunit>${app.module}</persistenceunit> 
        <drop>true</drop> 
        <create>false</create> 
        <outputfilename>${app.sql}-drop.sql</outputfilename> 
        <skip>${db.schema.gen.skip}</skip> 
       </componentProperties> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl (create sql schema) on project sample: There was an error creating the AntRun task. NullPointerException -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:3.0:hbm2ddl (create sql schema) on project framework: There was an error creating the AntRun task. 

उत्तर

12

कॉन्फ़िगरेशन का तरीका चींटी हाइबरनेट टूल प्लगइन के प्रत्यक्ष उपयोग में बदल गया। तो कॉन्फ़िगरेशन बिल्कुल उसी प्रारूप जैसा है जैसे एंटी प्लगइन की आवश्यकता के बिना अतिरिक्त taskDef की आवश्यकता के लिए। jpaconfiguration। अधिक जानकारी के लिए हाइबरनेट एंट टूल संदर्भ दस्तावेज देखें: http://docs.jboss.org/tools/3.3.0.Final/en/hibernatetools/html_single/index.html#d0e4651

एक जेपीए विन्यास आप निम्नलिखित इस्तेमाल कर सकते हैं के साथ एक hbm2ddl के लिए:

<plugin> 
    <!-- run "mvn hibernate3:hbm2ddl" to generate a schema --> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>hibernate3-maven-plugin</artifactId> 
    <version>3.0</version> 

    <configuration> 
     <hibernatetool> 
      <jpaconfiguration persistenceunit="unitname" /> 

      <hbm2ddl export="false" create="true" 
       update="true" format="true" outputfilename="schemaDiff.ddl" /> 

     </hibernatetool> 
    </configuration> 
</plugin> 

विफलताओं पर वहाँ "लक्ष्य/antrun/निर्माण main.xml" फाइल जो हाइबरनेट उपकरण कॉन्फ़िगर करता है। उपर्युक्त उदाहरण के लिए इस निम्नलिखित की तरह दिखता है:

<?xml version="1.0" encoding="UTF-8" ?> 
<project name="maven-antrun-" default="main" > 
<target name="main"> 
    <taskdef classname="org.hibernate.tool.ant.EnversHibernateToolTask" name="hibernatetool"/> 
    <mkdir dir="/home/xxx/workspace/projectname/target/sql/hibernate3"/> 
    <hibernatetool destdir="/home/xxx/workspace/projectname/target/sql/hibernate3"> 
    <jpaconfiguration persistenceunit="schemaDiff"/> 
    <hbm2ddl update="true" export="false" outputfilename="schemaDiff.ddl" format= 
"true" create="true"/> 
    </hibernatetool> 
</target> 
</project> 
+1

यह अभी भी कोई फर्क नहीं पड़ता है, मैं पहले की तरह ही त्रुटि देख रहा हूं। –

+0

प्रासंगिक डीबग संदेश इस मुद्दे को हल करने के लिए और संकेत दे सकता है। बस अपने maven कमांड में "-X" या "-debug" जोड़ें। – Kuhpid

+1

http://pastebin.com/2QLFjp4q - यहां देखें –

3

मैं इस एक ही मुद्दा था, और अंत में यह इस उदाहरण (http://www.celinio.net/techblog/?p=1125) का पालन करते हुए और अकेले प्लगइन के लिए हाइबरनेट deps निर्दिष्ट करने के द्वारा हल किया गया था। ऐसा इसलिए है क्योंकि मेरे मामले में मेरे पास एक अलग डोमेन ऑब्जेक्ट मॉड्यूल है जो केवल जेपीए 2 (कोई विशिष्ट हाइबरनेट संदर्भ) का उपयोग नहीं करता है, इसलिए मुझे इस मॉड्यूल के आश्रितों को प्रभावित करने के बारे में चिंता किए बिना डीडीएल पीढ़ी के लिए डीपीएस में खींचने की आवश्यकता है।

<plugin> 
<groupId>org.codehaus.mojo</groupId> 
<artifactId>hibernate3-maven-plugin</artifactId> 
<version>3.0</version> 
<executions> 
    <execution> 
     <id>create-schema</id> 
     <phase>process-test-resources</phase> 
     <goals> 
      <goal>run</goal> 
     </goals> 
     <configuration> 
      <hibernatetool destdir="${project.basedir}"> 
       <classpath> 
        <path 
         location="${project.basedir}/src/main/resources/mappings/" /> 
       </classpath> 
       <configuration 
        configurationfile="${project.basedir}/src/test/resources/hibernate.cfg.xml" /> 
       <hbm2ddl create="true" export="false" 
        drop="true" outputfilename="schema.sql" 
        format="true" console="false" /> 
      </hibernatetool> 
     </configuration> 
    </execution> 
</executions> 

मूल विचार लक्ष्य 'रन' का उपयोग और उसके बाद hibernatetool कॉन्फ़िगर करने के लिए निर्यातकों आप चाहते हैं चलाने के लिए है:

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>hibernate3-maven-plugin</artifactId> 
      <version>3.0</version> 
      <configuration> 
       <components> 
        <component> 
         <name>hbm2ddl</name> 
         <implementation>jpaconfiguration</implementation> 
        </component> 
       </components> 
       <hibernatetool> 
        <classpath> 
         <path location="${project.build.directory}/classes" /> 
         <path location="${project.basedir}/src/main/resources/META-INF/" /> 
        </classpath> 
        <jpaconfiguration persistenceunit="Configuration" /> 
        <hbm2ddl create="true" export="false" drop="true" 
         outputfilename="configuration.sql" format="true" console="true" /> 
       </hibernatetool> 
      </configuration> 
      <dependencies> 
       <dependency> 
        <groupId>org.hibernate.javax.persistence</groupId> 
        <artifactId>hibernate-jpa-2.0-api</artifactId> 
        <version>1.0.0.Final</version> 
       </dependency> 
       <dependency> 
        <groupId>org.hibernate</groupId> 
        <artifactId>hibernate-entitymanager</artifactId> 
        <version>3.6.7.Final</version> 
       </dependency> 
      </dependencies> 
     </plugin> 
    </plugins> 
</build> 
+2

यह समाधान मेरे लिए हाइबरनेट-जेपीए-2.0-एपीआई: 1.0.0 जोड़ा गया। फाइनल, हाइबरनेट-इकाई प्रबंधक: 3.6.8. अंतिम, हाइबरनेट-सत्यापनकर्ता: 4.2.8। अंतिम, हाइबरनेट-सत्यापनकर्ता: 4.2। 0. निर्भरता में अंतिम –

3

मैं इसे निम्नलिखित के रूप में काम करने के लिए है। तो आप टैग के अंदर अधिक निर्यातक कॉन्फ़िगरेशन जोड़कर एक साथ कई निर्यातकों को चला सकते हैं। अधिक जानकारी के लिए, यहां देखें http://docs.jboss.org/tools/2.0.0.GA/hibernatetools/en/html_single/index.html और http://mojo.codehaus.org/hibernate3-maven-plugin/examples/run-multiple-goals.html। मुझे पता लगाने में मुझे कुछ घंटे लगे। उम्मीद है कि मदद करो!