I am new to Spring and currently I compile my project into war file and put it in tomcat webapps folder or use tomcat manager page. I'm looking for something like 'npm start' in react or 'dotnet watch run' in net.core. They automatically rebuild project if tracking changes and all I have to do is refresh my localhost page. I have tried maven-plugin-tomcat also but they seemed outdated and throw exception when I run.
Asked
Active
Viewed 595 times
2
-
what execption ? are you using Maven or not ? how did you export to war file ? – Rookie007 Feb 10 '20 at 01:56
-
Either copy your compiled project to `webapps` or export a war files and copy that to your webapps diectory. – Scary Wombat Feb 10 '20 at 02:00
-
@Rookie007 yes I use Maven. Scary I know this way but this is annoyed when I have to switch between windows. – Vo Phu Feb 10 '20 at 02:05
-
For development, if you are using Eclipse you can have the webapp synchronised – Scary Wombat Feb 10 '20 at 02:07
-
@VoPhu if you are using Maven you should export to war file using `mvn install` if you are using eclipse it should show you runas>maven install. this way your project will get exported properly. – Rookie007 Feb 10 '20 at 02:19
-
Framework support is needed , how do you think the topcat will come from ?? – Vishwa Ratna Feb 10 '20 at 02:28
-
If it is maven based. You can use ```mvn install```. – Istiaque Hossain Feb 10 '20 at 02:36
-
Currently I still use mvn install to get war file and put the war exported file in tomcat web apps folder or deploy via tomcat manager page. In other platform, I only have to run a command line and while I change my source, the project is rebuilt in the back ground to update my the project. – Vo Phu Feb 10 '20 at 04:30
1 Answers
1
If you want to do the deployment from the terminal without taking help from the IDE. Then you should learn the maven/gradle commands for that. For maven it is something like this
mvn tomcat7:deploy
mvn tomcat7:run
mvn package
mvn clean install
Note: - These are some of the commands and they are not written in any specific order. First search and learn about these commands.
--> You need to have tomcat plugin in your pom.xml file. Otherwise it will throw error while packaging.

Silverfang
- 349
- 1
- 8
-
When my project is simple, it worked but after I added database, and create more java files It failed. Error: Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[Tomcat]]: A child container failed during start – Vo Phu Feb 10 '20 at 09:21
-
If you are using IDE, then delete your target or build folders. Rebuild your project and rebuild your artifact. See if it works now. If not then provide the full stack trace of the error. – Silverfang Feb 10 '20 at 09:42
-
Still the error, you can check full strack trace at this link: https://drive.google.com/file/d/1hb_dLaRvE6JRTP49He4Zap8WKAz5sgJi/view?usp=sharing This is just a small crud mvc project just require mysql installed, if you're interested I'll share with you. – Vo Phu Feb 12 '20 at 04:10
-
seems like the problem is most likely caused by servlet classes loaded by different class-loaders. see here https://stackoverflow.com/questions/11704069/servletdispatcher-cannot-be-cast-to-javax-servlet-servlet-exception-in-my-spring If it still not work you can share the github link, I will try to solve it from my end – Silverfang Feb 12 '20 at 04:47
-
Yes I tried but not work. Here is my github link: https://github.com/vonguyenphu/emp-app. Very appreciate your attention. – Vo Phu Feb 12 '20 at 07:28