2017-12-18 265 views
0

我遇到了一個問題,我無法在IntelliJ中調試Maven Sprint啓動REST API應用程序。應用程序啓動但不會停在任何斷點處。Intellij - 調試器在maven項目中不工作

此外,當我停止調試器時,我在日誌中看到下面的行,但是我可以看到java進程永不終止,並且當我第二次啓動應用程序時失敗,因爲服務器端口8080仍在使用中。

Disconnected from the target VM, address: '127.0.0.1:53020', transport: 'socket' 
Process finished with exit code -1 

在C:\ Users \ Bernhard.IdeaIC2017.3 \ system \ log的IntelliJ日誌中,我看到以下錯誤。

2017-12-15 07:22:30,761 [ 11899] INFO - .server.BuildMessageDispatcher - An existing connection was forcibly closed by the remote host 
java.io.IOException: An existing connection was forcibly closed by the remote host 
    at sun.nio.ch.SocketDispatcher.read0(Native Method) 
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) 
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) 
    at sun.nio.ch.IOUtil.read(IOUtil.java:192) 
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) 
    at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288) 
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1100) 
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:372) 
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123) 
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644) 
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579) 
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496) 
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458) 
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) 
    at java.lang.Thread.run(Thread.java:745) 

回答

0

經過一番搜索之後,我發現問題出在IntelliJ中我的Maven Run/Debug配置。我用它來啓動春季啓動REST API的命令行是

clean package -Drun.profiles=dev-us-east-1 -Drun.jvmArguments=-Denvironment=dev -DskipTests spring-boot:run 

看來,-Drun.jvmArguments=-Denvironment=dev java命令行屬性是罪魁禍首。當我刪除它時,斷點再次工作。

1

您可能可以用引號括住該參數的值。讀取整個命令行字符串的解析器可能因爲-D arg中的-D arg而窒息。

清潔套裝-Drun.profiles = DEV-美國東1 -Drun.jvmArguments = 「-Denvironment =開發」 -DskipTests春天啓動:運行

+0

嗨Jaraon,好oberservation。我確實有雙引號中的「-Denvironment = dev」。我相信Stackoverflow似乎在我的複製粘貼中刪除了它們... –