什么版本的 Java 可以与 Liquibase Maven 插件一起使用?

What version of Java works with the Liquibase Maven plugin?

是否有适用于 Java 9 的 Liquibase Maven 插件版本?我设置了以下 Maven 编译器插件:-

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.1</version>
      <configuration>
        <source>1.9</source>
        <target>1.9</target>
        <compilerArgument>-proc:none</compilerArgument>
        <fork>true</fork>
        <executable>${javac_path}</executable>
       </configuration>
       <executions>
         <execution>
           <id>default-testCompile</id>
           <phase>test-compile</phase>
           <goals>
             <goal>testCompile</goal>
           </goals>
         </execution>
       </executions>
    </plugin>
  </plugins>
</build>

并拥有这个 Maven liquibase 插件

<!-- Run the liquibase scripts -->
<plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>${version.liquibase}</version>
  <dependencies>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>${version.mysql}</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <id>build-test-database</id>
      <phase>process-test-classes</phase>
      <configuration>
        <driver>com.mysql.jdbc.Driver</driver>
        <url>${test.mysql.dataSource.url}</url>
        <username>${test.mysql.db.user}</username>
        <password>${test.mysql.db.password}</password>
        <changeLogFile>${project.build.directory}/db.changelog-master.xml</changeLogFile>
        <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
        <skip>${skipLiquibaseRun}</skip>
        <clearCheckSums>true</clearCheckSums>
      </configuration>
      <goals>
        <goal>update</goal>
      </goals>
    </execution>
  </executions>
</plugin>

但是 运行 插件因错误而死

[INFO] --- liquibase-maven-plugin:3.3.0:update (build-local-database) @ database ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /home/jboss/.jenkins/workspace/springboard/session/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO]   File: /home/jboss/.jenkins/workspace/springboard/database/src/main/resources/liquibase.properties
[INFO] ------------------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Source option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.

当我将编译器版本更改为“1.8”时,不会发生这种情况。

基于这个问题 - https://github.com/liquibase/liquibase/pull/710 我认为此时最好的选择是克隆 liquibase git 存储库,在本地构建它并为 liquibase 使用 >= 3.6.0-SNAPSHOT。

注:3.6.0-SNAPSHOT是高手回答时的版本:)

尝试将您的 maven-compiler-plugin 配置更改为

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version> <!-- JDK9 compatible version-->
<configuration>
    <source>9</source> <!--not 1.9-->
    <target>9</target>
    <compilerArgument>-proc:none</compilerArgument>
    <fork>true</fork>
    <executable>${javac_path}</executable>
</configuration>

原因是被解析的 Java 版本不是 1.9,而是自 JDK9 发布以来的 9。