无法在JDK 9 for hibernate上构建谷歌容易出错的代码

时间:2018-05-18 17:37:59

标签: hibernate maven java-9 errorprone

我无法构建我的代码,该代码利用hibernate生成一些类,并且谷歌容易出现静态代码分析。我以为我启用了java.sql模块,但我仍然无法为Hibernate生成类,所以我的编译失败了:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project model: Fatal error compiling: CompilerException: InvocationTargetException: java.lang.NoClassDefFoundError: java/sql/Date: java.sql.Date -> [Help 1]

这是在我的构建部分:

<plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven.compiler.plugin.version}</version>
          <configuration>
            <compilerId>javac-with-errorprone</compilerId>
            <forceJavacCompilerUse>true</forceJavacCompilerUse>
            <source>${java.version}</source>
            <target>${java.version}</target>
            <compilerArgs>
              <arg>--add-modules</arg>
              <arg>java.sql</arg>
            </compilerArgs>
            <compilerArguments>
              <endorseddirs>${endorsed.dir}</endorseddirs>
            </compilerArguments>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.codehaus.plexus</groupId>
              <artifactId>plexus-compiler-javac-errorprone</artifactId>
              <version>2.8.4</version>
            </dependency>
            <!-- override plexus-compiler-javac-errorprone's dependency on
                             Error Prone with the latest version -->
            <dependency>
              <groupId>com.google.errorprone</groupId>
              <artifactId>error_prone_core</artifactId>
              <version>2.3.1</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-jpamodelgen -->
            <dependency>
              <groupId>org.hibernate</groupId>
              <artifactId>hibernate-jpamodelgen</artifactId>
              <version>5.2.12.Final</version>
            </dependency>
            <!-- Added for modularity JDK 9+ -->
            <dependency>
              <groupId>javax.xml.bind</groupId>
              <artifactId>jaxb-api</artifactId>
              <version>2.3.0</version>
            </dependency>
            <dependency>
              <groupId>com.sun.xml.bind</groupId>
              <artifactId>jaxb-core</artifactId>
              <version>2.3.0</version>
            </dependency>
            <dependency>
              <groupId>com.sun.xml.bind</groupId>
              <artifactId>jaxb-impl</artifactId>
              <version>2.3.0</version>
            </dependency>
          </dependencies>
        </plugin>

根据这个:https://github.com/google/error-prone/issues/448

只要配置它就应该有效。

0 个答案:

没有答案