0

我无法构建我的代码,它利用休眠生成一些类,并且谷歌容易出错以进行静态代码分析。我以为我启用了 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

只要配置好,它就应该可以工作。

4

0 回答 0