简体   繁体   中英

Intellij - Debugger not working in maven project

I came across an issue where I am not able to debug a maven sprint boot REST API application in IntelliJ. The application starts up but won't stop at any breakpoint.

Additionally when I stop the debugger I see below lines in the log, but I can see that the java process never terminates and when I start the app the 2nd time it fails because the server port 8080 is still in use.

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

In the IntelliJ logs at C:\\Users\\Bernhard.IdeaIC2017.3\\system\\log I see the following error.

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)

You can probably wrap the value of that argument in quotations. The parser that reads the entire command line string is probably choking because of the -D arg within a -D arg.

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

After some searching I found that the problem is with my Maven Run/Debug configuration in IntelliJ. The command line I use to start the spring boot rest api is

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

It appears that the -Drun.jvmArguments=-Denvironment=dev java command line property is the culprit. When I remove it the break points work again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM