How to stop a maven project started in Netbeans

后端 未结 1 1129
你的背包
你的背包 2021-01-22 14:18

I have a project in NetBeans that starts with a main function, that takes arguments. When I hit the \"Stop\" Button, the project continues running, but there is no output anymor

相关标签:
1条回答
  • 2021-01-22 14:53

    When you hit "Stop" in the NetBeans output, NB stops the maven process, but maven had spawned the actual program output, so the stop command is not handed over to your program.

    NetBeans calls the exec-maven-plugin with the 'exec' goal by default. If you change it to the 'java' goal there is no new process. After the change below, the 'Run' section in your projects 'Properties' will be empty and of no use. I did not test what happens if you call 'System.exit' or similar in this scenario.

    Also note, that you have to take care that you modify the version number here by yourself from now on.

    You have to go to Projects window, right click your project, go to the Properties and select the Actions element and the the Run project entry. It will look like this:

    You have to modify

    1. Execute Goals: to process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:java (change the exec in the end to java).
    2. Set Properties: to exec.mainClass=de.steamnet.stopfromnetbeans.Main exec.classpath=%classpath exec.args=First Second 'Third Space'

    So that it looks like this:

    From now on, Maven will not fork a new process, so when you hit "Stop" it will actually Stop the process.

    0 讨论(0)
提交回复
热议问题