无法在JDK 9上为hibernate生成google易出错的代码

无法在JDK 9上为hibernate生成google易出错的代码,hibernate,maven,java-9,errorprone,Hibernate,Maven,Java 9,Errorprone,我无法构建使用hibernate生成某些类的代码,也无法构建用于静态代码分析的google易出错代码。我以为我启用了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:

我无法构建使用hibernate生成某些类的代码,也无法构建用于静态代码分析的google易出错代码。我以为我启用了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>

org.apache.maven.plugins


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

sql日期在Java9中的不同模块中。除此之外,为什么您要将所有这些依赖项定义为插件依赖项而不是构建依赖项?我怀疑它是否正确……我相信hibernate插件在构建时需要它们。在类路径上编译代码时,默认情况下会解析java.sql模块,因此我假设不需要添加模块java.sql。图片中是否有一个自定义类加载器授权给引导加载器而不是系统类加载器?这可以解释为什么java.sql类型的定义加载器是自JDK 9以来的平台类加载器。我不确定,我知道从等式中删除容易出错的加载器确实允许我编译(使用java.sql参数)。