2016-07-31 6 views
1

JOOQ 및 Maven을 처음 사용합니다. JOOQ의 문서에 따르면 스키마를 제공하여 Pojo를 생성하려고합니다. 커맨드 라인 방식으로 시도했지만 완벽하게 작동했습니다. Eclipse java 프로젝트에서 동일한 구성을 추가했다. 아래는 내 pom.mxlJOOQ : Eclipse에서 maven을 사용하여 소스를 생성하면 파일이 생성되지 않습니다.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>PojoGenerator</groupId> 
    <artifactId>PojoGenerator</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>rutherford.pojo</name> 
    <build> 
     <sourceDirectory>src</sourceDirectory> 
     <pluginManagement> 

      <plugins> 
       <plugin> 
        <!-- <artifactId>maven-compiler-plugin</artifactId> 
        <version>3.5.1</version> 
        <configuration> 
         <source>1.8</source> 
         <target>1.8</target> 
        </configuration> 
       </plugin> 

       <plugin> --> 

        <!-- Specify the maven code generator plugin --> 
        <!-- Use org.jooq for the Open Source edition org.jooq.pro for commercial 
         editions, org.jooq.pro-java-6 for commercial editions with Java 6 support, 
         org.jooq.trial for the free trial edition --> 
        <groupId>org.jooq</groupId> 
        <artifactId>jooq-codegen-maven</artifactId> 
        <version>3.8.4</version> 

        <!-- The plugin should hook into the generate goal --> 
        <executions> 
         <execution> 
          <goals> 
           <goal>generate</goal> 
          </goals> 
         </execution> 
        </executions> 

        <!-- Manage the plugin's dependency. In this example, we'll use a PostgreSQL 
         database --> 
        <dependencies> 
         <dependency> 
          <groupId>org.postgresql</groupId> 
          <artifactId>postgresql</artifactId> 
          <version>9.4-1201-jdbc41</version> 
         </dependency> 
        </dependencies> 

        <!-- Specify the plugin configuration. The configuration format is the 
         same as for the standalone code generator --> 
        <configuration> 

         <!-- JDBC connection parameters --> 
         <jdbc> 
          <driver>org.postgresql.Driver</driver> 
          <url>jdbc:postgresql://localhost:5432/test</url> 
          <user>postgres</user> 
          <password>test</password> 
         </jdbc> 

         <!-- Generator parameters --> 
         <generator> 
          <database> 
           <name>org.jooq.util.postgres.PostgresDatabase</name> 
           <includes>.*</includes> 
           <excludes></excludes> 
           <inputSchema>public</inputSchema> 
          </database> 
          <target> 
           <packageName>com.generated.pojo</packageName> 
           <directory>${project.build.directory}/src</directory> 

          </target> 
         </generator> 
        </configuration> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    </build> 

</project> 

리소스를 생성 해 보았습니다. 그것은 BUILD SUCCESS라고 말하지만, 생성 된 Pojos를 어디에서나 볼 수는 없습니다. 제가 누락 된 부분을 알려주세요.

+0

jOOQ 코드 생성기 플러그인을 ''이 아닌''안에 넣어야하는 이유가 있습니까? –

+0

이 태그를 제거하면'플러그인 실행이주기 설정에 포함되지 않습니다 : org.jooq : jooq-codegen-maven : 3.8.4 : generate (실행 : default, phase : generate-sources) ' –

+0

Aha, 내가 참조. 이 잘 알려진 이클립스의 m2e 버그가 있습니다. [사람들은''태그를 사용하여 "수정"을 제안합니다.] (http://stackoverflow.com/q/6352208/521799). 메이븐 빌드. –

답변

1

<pluginManagement>은 재사용을위한 일반적인 구성을 선언하는 데 도움이되므로 여전히 빌드에 플러그인을 추가해야합니다.

<build> 
    <pluginManagement>...</pluginManagement> 
    <plugins> 
     <plugin> 
      <groupId>org.jooq</groupId> 
      <artifactId>jooq-codegen-maven</artifactId> 
      <execution>...</execution> 
     </plugin> 
    </plugins> 
</build> 

도 여기에이 질문을 참조하십시오 :이 경우 Maven: What is pluginManagement?

을, 그냥 ignore this well-known issue in Eclipse and avoid the <pluginManagement> element 아마 간단합니다.