3
[INFO] Scanning for projects...
[INFO] ---------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] test.master
[INFO] test.generator
[INFO] test.model
[INFO] test.dal
[INFO] test.service
[INFO] test.web
[INFO]                                                                         
[INFO] ---------------------------------------------
[INFO] Building test.master 0.0.1-SNAPSHOT
[INFO] ---------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test.master ---
[INFO] 
[INFO] --- maven-jdeps-plugin:3.1.1:jdkinternals (default) @ test.master ---
[INFO] 
[INFO] --- maven-jdeps-plugin:3.1.1:test-jdkinternals (default) @ test.master ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ test.master ---
[INFO] Installing C:\Users\cora_kwok\git\backend2\pom.xml to   C:\Users\cora_kwok\.m2\repository\com\kinetix\test.master\0.0.1-SNAPSHOT\test.master-0.0.1-SNAPSHOT.pom
[INFO]                                                                         
[INFO] ----------------------------------------------------------
[INFO] Building test.generator 1.0.0
[INFO] -------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test.generator ---
[INFO] Deleting C:\Users\cora_kwok\git\backend2\test.generator\target
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ test.generator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\cora_kwok\git\backend2\test.generator\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ test.generator ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\cora_kwok\git\backend2\test.generator\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] -----------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] test.master ............................. SUCCESS [  0.703 s]
[INFO] test.generator ............................ FAILURE [  0.790 s]
[INFO] test.model ......................................... SKIPPED
[INFO] test.dal ........................................... SKIPPED
[INFO] test.service ....................................... SKIPPED
[INFO] test.web ........................................... SKIPPED
[INFO] ---------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------------------------------------
[INFO] Total time: 1.715 s
[INFO] Finished at: 2018-05-09T14:14:05+08:00
[INFO] Final Memory: 11M/40M
[INFO] ---------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test.generator: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]    http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :test.generator

下面是我的 pom.xml 模块 test.generator 。我想用jdeps检查jdk10的3rd方依赖,准备jdk10升级,但是,当我尝试运行时,出现上述错误。

我确实删除了我的 m2.repository 文件夹,但同样的错误仍然存​​在。我已经安装了 jdk10 和 jre10。但是,它似乎在 Maven 构建期间无法识别 jdk10。

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.kinetix</groupId>
    <artifactId>test.master</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
  <groupId>com.kinetix.test</groupId>
  <artifactId>test.generator</artifactId>
  <version>1.0.0</version>
  <name>test.generator</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <java-version>10.0.1</java-version>
  </properties>
  <dependencies>
    <dependency>
        <groupId>org.jasypt</groupId>
        <artifactId>jasypt</artifactId>
        <version>1.9.2</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

我不知道为什么它无法识别 10.0.1 版本的 jdk10 小于 1.7 版本。

4

1 回答 1

5

您必须像这样通过 pluginManagement 定义 maven-compiler 插件:

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  ..
  </build>

此外,您应该像这样定义属性:

  <properties>
    <maven.compiler.source>10</maven.compiler.source>
    <maven.compiler.target>10</maven.compiler.target>
    <maven.compiler.release>10</maven.compiler.release>
  </properties>

你有一个多模块构建,你有一个应该定义上述内容的父级。此外,我强烈建议定义您正在使用的所有插件,如 maven-resources-plugin 等,如上面的 maven-compiler-plugin ......并且使用最新版本而不是这样的古老版本......

于 2018-05-09T07:41:02.523 回答