Maven在编译期间卡住了

时间:2017-03-21 21:02:39

标签: maven build

我正在使用mvn clean install命令,看起来maven在编译类时遇到了一些死锁,它仍处于这种状态 -

    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ service-nextgen ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ service-nextgen ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 363 source files to C:\Users\service-nextgen\target\classes

如果我使用java Visual VM可视化线程转储,我会收到以下信息:

"RMI TCP Connection(3)-3.202.32.1" #20 daemon prio=5 os_prio=0 tid=0x000000001f246000 nid=0x2454 runnable [0x000000002118e000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
    - locked <0x00000000ff832010> (a java.io.BufferedInputStream)
    at java.io.FilterInputStream.read(FilterInputStream.java:83)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:550)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$240(TCPTransport.java:683)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$2/10873147.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
    - <0x00000000ff8321d0> (a java.util.concurrent.ThreadPoolExecutor$Worker)


"main" #1 prio=5 os_prio=0 tid=0x0000000001ff8000 nid=0x2b38 runnable [0x0000000002501000]
   java.lang.Thread.State: RUNNABLE
    at java.lang.Object.hashCode(Native Method)
    at java.util.HashMap.hash(HashMap.java:338)
    at java.util.HashMap.get(HashMap.java:556)
    at com.sun.tools.javac.comp.Infer$InferenceContext.cachedCapture(Infer.java:2309)

不确定如何找到根本原因。

1 个答案:

答案 0 :(得分:2)

我在maven编译器插件中添加Compiler args后能够识别出问题:<compilerArgs> <arg>-verbose</arg> <arg>-Xlint:all,-options,-path</arg> </compilerArgs>这在编译期间逐个显示了这些类,我能够看到编译器卡在哪里。

maven配置类似于this

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <compilerArgs>
            <arg>-verbose</arg>
            <arg>-Xlint:all,-options,-path</arg>
          </compilerArgs>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>

这类错误的一个可能的罪魁祸首是Annotations Processors,它在编译阶段生成代码。