有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

有没有一个版本的Liquibase Maven插件可以与Java 9一起使用?我已经设置了以下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”时,不会发生这种情况


共 (2) 个答案

  1. # 1 楼答案

    基于这个问题https://github.com/liquibase/liquibase/pull/710 我认为此时最好的选择是克隆liquibase git回购协议,在本地构建并使用>;=3.6.0-liquibase的快照

    注:3.6.0-SNAPSHOT是在回答此问题时主服务器所在的版本:)

  2. # 2 楼答案

    尝试将maven编译器插件配置更改为

    <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