2014-11-08 7 views
0

최대 절전 모드 도구를 사용하여 프로젝트에서 pojo와 dao를 생성하고 있습니다. 그것은 현재 실행> 최대 절전 모드 코드 생성을 사용하여 Hibernate 퍼스펙티브에서 작업 중이다 ... 그러나, 나는 이것을 좀 더 복잡한 빌드의 일부로 자동화하고 싶다. 내가 사전 처리를하고, 최대 절전 모드 코드 생성을 실행하고, 후 처리. 이에 따른 빌드 오류와최대 절전 모드 도구가 Maven 종속 일 때 Ant에서 HibernateToolTask를 실행하는 방법

taskdef class org.hibernate.tool.ant.HibernateToolTask cannot be found using the classloader AntClassLoader[] 

: 나는이 작업을 수행하기위한 Ant 빌드 파일을 가지고,하지만 난 메이븐 참조하는 방법을 모른다는 항아리에게 내가이 경고를 얻고있다

<?xml version="1.0" ?> 
<!DOCTYPE project> 
<project name="Hibernate Tools hbm2java" default="gensrc"> 

    <path id="tools"> 
     <!-- 
      Here { 
     --> 
     <path location="lib/hibernate-tools-4.3.1.CR1.jar"/> 
     <!-- more dependencies... --> 
     <!-- 
      } 
     --> 
     ... 
    </path> 
    <taskdef name="gen-src" classname="org.hibernate.tool.ant.HibernateToolTask" 
      classpathref="tools" /> 
    <target name="gensrc"> 
     ... 
    </target> 
</project> 

종속성 :

BUILD FAILED 
/.../hibernate-gen.xml:16: taskdef class org.hibernate.tool.ant.HibernateToolTask cannot be found using the classloader AntClassLoader[] 

가 어떻게이 org.hibernate.tool.ant.HibernateToolTask를 호출 메이븐 의존성에서 항아리를 참조 할 수 있습니다 ?

답변

1

pojo 생성을 자동화하려면 paven.xml 파일에 maven-antrun-plugin 플러그인을 추가 할 수 있습니다. 이 플러그인의 작업 섹션에서 직접 설명한 Ant 작업을 직접 호출 할 수 있습니다.

<build> 
    ... 
    <plugins> 
     <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
      <execution> 
       <phase>generate-sources</phase> 
       <configuration> 
       <tasks> 
        <taskdef name="hibernatetool" 
          classname="org.hibernate.tool.ant.HibernateToolTask" 
          classpathref="maven.dependency.classpath"/> 

        <hbm2java output="src/generated"> 
         <fileset dir="src/hibernate"> 
          <include name="**/*.hbm.xml"/> 
         </fileset> 
        </hbm2java> 
       </tasks> 
       </configuration> 
       <goals> 
       <goal>run</goal> 
       </goals> 
      </execution> 
      </executions> 
     </plugin> 
    </plugins> 
    </build> 

그렇지 않으면 최대 절전 모드 도구를 사용하여 pojo 클래스를 생성하여 자동화 할 수 있습니다. hbm에서 pojos를 생성하려면이 git project을 참조하십시오.