【问题标题】:Maven hangs at compiling,my project use java 11, how to fix it?Maven在编译时挂起,我的项目使用java 11,如何解决?
【发布时间】:2019-04-23 10:05:34
【问题描述】:

我的项目使用 java 11,当我使用“mvn clean compile -X -e”时,它会挂在这里:

[INFO] Compiling 8 source files to /home/liuxu/IdeaProjects/papaya/papaya-promotion-taoke-starter/target/classes

什么都没有发生,挂在这里。该项目是spring boot应用程序。

这是我的编译器配置:

[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal:          org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <basedir default-value="${basedir}"/>
  <buildDirectory default-value="${project.build.directory}"/>
  <compilePath default-value="${project.compileClasspathElements}"/>
  <compileSourceRoots default-value="${project.compileSourceRoots}"/>
  <compilerId default-value="javac">${maven.compiler.compilerId}</compilerId>
  <compilerReuseStrategy default-value="${reuseCreated}">${maven.compiler.compilerReuseStrategy}</compilerReuseStrategy>
  <compilerVersion>${maven.compiler.compilerVersion}</compilerVersion>
  <debug default-value="true">${maven.compiler.debug}</debug>
  <debuglevel>${maven.compiler.debuglevel}</debuglevel>
  <encoding default-value="${project.build.sourceEncoding}">${encoding}</encoding>
  <executable>${maven.compiler.executable}</executable>
  <failOnError default-value="true">${maven.compiler.failOnError}</failOnError>
  <failOnWarning default-value="false">${maven.compiler.failOnWarning}</failOnWarning>
  <forceJavacCompilerUse default-value="false">${maven.compiler.forceJavacCompilerUse}</forceJavacCompilerUse>
  <fork default-value="false">${maven.compiler.fork}</fork>
  <generatedSourcesDirectory default-value="${project.build.directory}/generated-sources/annotations"/>
  <maxmem>${maven.compiler.maxmem}</maxmem>
  <meminitial>${maven.compiler.meminitial}</meminitial>
  <mojoExecution default-value="${mojoExecution}"/>
  <optimize default-value="false">${maven.compiler.optimize}</optimize>
  <outputDirectory default-value="${project.build.outputDirectory}"/>
  <parameters default-value="false">true</parameters>
  <project default-value="${project}"/>
  <projectArtifact default-value="${project.artifact}"/>
  <release>11</release>
  <session default-value="${session}"/>
  <showDeprecation default-value="false">${maven.compiler.showDeprecation}</showDeprecation>
  <showWarnings default-value="false">${maven.compiler.showWarnings}</showWarnings>
  <skipMain>${maven.main.skip}</skipMain>
  <skipMultiThreadWarning default-value="false">${maven.compiler.skipMultiThreadWarning}</skipMultiThreadWarning>
  <source default-value="1.6">${maven.compiler.source}</source>
  <staleMillis default-value="0">${lastModGranularityMs}</staleMillis>
  <target default-value="1.6">${maven.compiler.target}</target>
  <useIncrementalCompilation default-value="true">false</useIncrementalCompilation>
  <verbose default-value="false">${maven.compiler.verbose}</verbose>
</configuration>

【问题讨论】:

  • 您在 pom.xml 中定义的项目属性中有什么 maven.compiler.source 版本?
  • 你用 JDK8 测试过,看看它到底挂在哪里了吗?在编译期间的测试中?
  • @khmarbaise 用 JDK8 编译;全部通过,没有挂起
  • 所以现在我们可以继续了。构建挂在哪里?以及如何?
  • @khmarbaise 将 jdk 版本切换到 11,然后编译挂在包含 3rd jar 的 maven 模块上。 jar 是用 jdk 6 编译的,或者可能是 jdk 7。

标签: spring maven spring-boot


【解决方案1】:

请检查您是否在 pom.xml 的项目属性中正确定义了 Java 版本

<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>

其次检查插件版本是否配置如下(也是pom.xml):

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
            <release>11</release>
        </configuration>
    </plugin>
</plugins>

【讨论】:

  • 我已经将编译器参数设置为 java 11,和你的帖子一样,它仍然挂起
  • [DEBUG] incrementalBuildHelper#beforeRebuildExecution [INFO] 编译8个源文件到/home/liuxu/IdeaProjects/papaya/papaya-promotion-taoke-starter/target/classes
  • 有些奇怪,另一个 maven 模块编译时没有挂起,那个 maven 模块是纯 java 项目,没有 3rd jar。这个 maven 模块 'papaya-promotion-taoke-starter' 有低版本的 java jars。那可能吗?对不起!我的英语很烂。
猜你喜欢
  • 2018-08-30
  • 2015-06-02
  • 2017-05-10
  • 2016-10-01
  • 1970-01-01
  • 2021-07-23
  • 2019-08-31
  • 1970-01-01
相关资源
最近更新 更多