How to prevent Eclipse+Tomcat from running current

2019-06-04 00:55发布

问题:

This may well prove to be a simple config change, but I can't seem to find an obvious setting to solve the following problem:

I have a Vaadin project in Eclipse, which is configured to be debugged with Tomcat v6. If I select the top of the project in the project explorer and hit debug, the eclipse browser launches and my web app opens with the following url:

http://localhost:8080/MyVaadinProject/ THIS WORKS

However, if I'm currently looking at a java file (say Myproject.java), Eclipse tries to open the java file at this url:

http://localhost:8080/MyVaadinProject/WEB-INF/classes/com/example/myproject/Myproject.java 

Of course, that produces a 404.

Having to deselect/close my java files every time I want to debug is quite tedious. Is there some way to prevent this behaviour in eclipse?

I am on OSX Lion, Eclipse version 3.7.2.

Thanks!

回答1:

When running the project, instead of highlighting the class file in the Project Explorer, highlight the very base of the project before running.

This is what we want to run anyway, not the class file itself.



回答2:

Go to

Windows -> Preferences -> Run/Debug -> Launching

There, at the bottom, select "Always launch the previously launched application". Now you just have to click your project name in the package explorer and do a Run As -> Run on Server once.

After that launch, you will just need to hit the Run Button and your application should always start the way it should be.