How to prevent Eclipse+Tomcat from running current class instead of project (Vaadin)

喜欢而已 提交于 2020-01-03 04:21:05

问题


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.



来源:https://stackoverflow.com/questions/11570418/how-to-prevent-eclipsetomcat-from-running-current-class-instead-of-project-vaa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!