Creating and debugging app with springmvc and ecli

2019-08-13 12:13发布

I currently have a sprimgmvc app that uses maven. I am currently using mvn:package to build war and deploy it to tomcat to develop and this is getting very cumbersome. I dont have the eclipse configured to automatically build and deploy to tomcat for that matter?

Can anyone please provide me steps that I need to take so that if I make any changes in my project I can just hit save and run and it will deploy to the tomcat OR a way in which I dont use tomcat but use maybe jetty or something else to build and test my app?

Thank you

3条回答
甜甜的少女心
2楼-- · 2019-08-13 12:17

I was able to make this work using some helpers from: Running Tomcat from within Eclipse always gives me 404 (but index.html works) and following these steps:

  1. I suspected that there was something wrong with the initial set up in eclipse. So, I closed the project in eclipse using: Right Click project > Close Project
  2. Then I deleted any files related with eclipse from the folder. These were: .settings, .project, .classpath
  3. I then Re-imported the project as maven project.
  4. I used Window > Show view > server view
  5. In the server view I created a new server and pointed it to XAMPP > tomcat since I already had tomcat.
  6. Right click on the project > Run As > Run on Server.
  7. It should run properly at that point in the browser as well

Make sure to check Right Click Project > Properties > Deployment Assembly - There should be Maven Dependencies added to the project and the deploy path for that should be "WEB-INF/lib"

查看更多
相关推荐>>
3楼-- · 2019-08-13 12:21

download STS > Import your project as maven project to the new workspace > mvn install (only once to download all your dependencies) > run AS > Server > baam! For any other eclipse version pretty much the same but you need to open the server window and configure tomcat , basically open the server tab > new > select your tomcat installation path and then .. just run it on the server. You can even modify code while running your app.

查看更多
闹够了就滚
4楼-- · 2019-08-13 12:43

here is a my way to debug and run maven web project with eclipse. though code is not hot deployed but it works fine for me.

Steps are as follows

  • open command prompt and go to your project directory. Lets say it is /opt/myhome/myproj

  • run mvnDebug tomcat:run command, make sure you have mvn and mvnDebug at system path

  • A message will be appeared like one mentioned in screenshot attached below, this states that maven is waiting for remote connection.

    Waiting for remote debugging

Now we need to Remotely connect to maven from IDE. To do that

  • Right click on the project and select "DebugAs" ---> "Debug configuration" Select Debug Configuration

  • Add an new entry under Remote Java application with highlighted details and then select Debug button. enter image description here

  • switch back to your terminal and you will get a screen like one displayed below enter image description here

  • your web app is ready to debug, put a break point and call it and your IDE will switch to debug perspective enter image description here

We are done with it. now if you make some changes in your code. you need to stop it from terminal with Ctrl-C and re-execute mvnDebug tomcat:run and then Remote Debug from IDE.

As i mentioned in starting code is not hot deployable as in local debug mode but it is pretty much better approach than rebuilding war and deploy it to external tomcat instance.

I hope this targets your query

查看更多
登录 后发表回答