我如何解决使用jooq-maven-plugin 3.7.3,Maven 3.3.9,Java 1.8.0_51和OS X 10.10.4获得的NullPointerException?
[错误]无法在项目my-app上执行目标org.jooq:jooq-codegen-maven:3.7.3:generate(default-cli):运行jOOQ代码生成工具时出错:NullPointerException - > [帮助1] org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标org.jooq:jooq-codegen-maven:3.7.3:在项目my-app上生成(default-cli):运行jOOQ代码生成工具时出错 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 在org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) 在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) 在org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) 在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) 在org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:497) 在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 引起:org.apache.maven.plugin.MojoExecutionException:运行jOOQ代码生成工具时出错 在org.jooq.util.maven.Plugin.execute(Plugin.java:134) 在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) ......还有20个 引起:java.lang.NullPointerException 在org.jooq.util.maven.Plugin.execute(Plugin.java:118) ......还有22个
根据代码on Github,抛出NPE的线是
String dir = generator.getTarget().getDirectory();
我在下面配置的目标目录确实存在,我尝试了相对和绝对路径,并且没有使用属性来设置它。
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<properties>
<db>myappdb</db>
<db.driver>com.mysql.jdbc.Driver</db.driver>
<db.jdbc>jdbc:mysql://localhost</db.jdbc>
<db.url>${db.jdbc}/${db}</db.url>
<db.user>root</db.user>
<db.pass>rootpass</db.pass>
<jaxb-api.version>2.2.6</jaxb-api.version>
<jooq.version>3.7.3</jooq.version>
<jooq.dialect>org.jooq.util.mysql.MySQLDatabase</jooq.dialect>
<jooq.gen.directory>target</jooq.gen.directory>
<jooq.gen.package>com.mycompany.app.jooq</jooq.gen.package>
<junit.version>3.8.1</junit.version>
<mysql.driver.version>5.1.38</mysql.driver.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<executions>
<execution>
<id>jooq-generate</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<jdbc>
<driver>${db.driver}</driver>
<url>${db.url}</url>
<user>${db.user}</user>
<password>${db.pass}</password>
</jdbc>
<generator>
<database>
<name>${jooq.dialect}</name>
<includes>.*</includes>
<excludes> UNUSED_TABLE
| PREFIX_.*
| SECRET_SCHEMA\.SECRET_TABLE # This table (qualified name) should not be generated
| SECRET_ROUTINE # This routine (unqualified name) ...
</excludes>
<inputSchema>${db}</inputSchema>
<!--outputSchema /-->
<!--dateAsTimestamp>true</dateAsTimestamp -->
</database>
<generate>
<relations>true</relations>
<deprecated>true</deprecated>
<instanceFields>true</instanceFields>
<generatedAnnotation>true</generatedAnnotation>
<records>true</records>
<pojos>true</pojos>
<immutablePojos>true</immutablePojos>
<interfaces>true</interfaces>
<daos>true</daos>
<jpaAnnotations>true</jpaAnnotations>
<validationAnnotations>true</validationAnnotations>
<springAnnotations>true</springAnnotations>
<globalObjectReferences>true</globalObjectReferences>
<fluentSetters>false</fluentSetters>
</generate>
<target>
<packageName>${jooq.gen.package}</packageName>
<directory>${jooq.gen.directory}</directory>
</target>
</generator>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.driver.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>