How to cleanly stop m2e cargo:run from Eclipse?

2019-06-19 06:20发布

Using the run mojo from the cargo-maven2-plugin I would like to know of a better way to shut down the container.

The console output says Ctrl+C to stop, but that seems to do nothing.

If I terminate, it leaves an orphan java.exe process that I have to kill myself.

Am I doing something wrong? This is a little cumbersome.

Edit: I am usign Tomcat in a standalone config. If I use embedded Jetty, naturally terminate works, however we need Tomcat.

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-19 06:51

The CTRL+C thing seems to be a known Eclipse/Jetty issue. The last post says that issuing mvn cargo:stop would stop an already running container, however it doesn't work for me—albeit, I've only made some quick test a with an archetype generated webapp.

Using Eclipse Indigo Service Release 1 (20110916-0149) if I issue mvn cargo:run and wait for the container to boot (for now it's Jetty, no configurations; let's see if you can get it working like this) clicking on the big red Terminate button kills the running process and no lingering java{,w}.exe are left behind.

I don't know how do you issue mvn cargo:run from Eclipse right now, but maybe you're using it as an External Tool (and that's why a process is left behind). If you have m2eclipse installed you should create Maven run configurations for it like this:

Run --> Run Configurations --> Maven build --> right click --> New

It should be straightforward from here on.

(I've found two Eclipse bug tickets (here and here) that seems to be related to Eclipse's inability to read a healthy CTRL+C via it's console.)


I've verified that when I'm starting an external Tomcat (7.0.23) instance with mvn cargo:run from Eclipse via the m2e plugin (after the container have started) CTRL+C indeed doesn't work.

After this I've ran mvn cargo:run from my Cygwin console. The result was the same.

Finally I've tried it from Windows's cmd and it worked.

My guess is that this is a bug in the cargo-maven-plugin.

Running mvn cargo:stop from either Eclipse or Cygwin did the trick for me.

You can run the cargo plugin from Eclipse by creating a Maven build Run or Debug configuration in Eclipse.

查看更多
别忘想泡老子
3楼-- · 2019-06-19 06:54

In general if you run Cargo using an Eclipse Maven launcher in DEBUG mode (i.e. Debug as --> Maven build...), killing the process on the Eclipse console (the red button) doesn't leave any orphan process...

I don't know why, but it works :) At least on my workspace

查看更多
登录 后发表回答