Spring MVC Project Deployment

I developed a small MVC project using Spring MVC, Hibernate, MySQL, Maven, and Tomcat. I can run and test the application (locally) seamlessly.

Now I need to publish / deploy this project on a (online) server on which only Tomcat is installed. How can I publish / deploy a project on the Internet? Is there any special assembly I have to do? What files will I upload and where?

+6
source share
3 answers

There are several types of development options available.

For development on a local EAR (Explode ARchive), the project type is usually used (because you can easily do a hot deployment on servery). But WAR (Web ARchive) is used for production (basically it is the same EAR archive, but compressed using the ZIP algorithm).

If you want to deploy your project to a remote Tomcat server, make your project a WAR archive and upload it to the Tomcat Webapps directory. Then you may need to restart Tomcat. But this is a manual deployment method.

It’s better to use automated build tools (e.g. Maven ) that can compile your project, run unit tests, deploy to a web server (local or remote), etc.

This example is a great example of deploying your project to a Tomcat server using Maven tomcat-maven-plugin : http://www.mkyong.com/maven/how-to-deploy-maven-based-war-file-to-tomcat/

Good luck;)

+6
source

Make mvn clean install and you will get the .war file in your target web module directory. Copy it and paste it into the tomcat_home / webapps directory and restart tomcat. This is it. Now you can access it in any configured port (for example: http://localhost:8080/<your webapp war name> ). let's say your military name is myapp.war, and then tomcat extracted it to the myapp folder in webapps. so your url will be http://localhost:8080/myapp

0
source

The maven deploy command usually gets errors for various reasons. if you are running a Unix / Linux system, I recommend using the rsync method on the console. (You can write your own shell script to manage easily). This not only helps to deploy without problems, but also helps to get time when redeploying (only downloading changed / new files). Since maven deploy / redeploy loads your project as a package in jar / war. However, the rysnc method loads the project files one by one.

Before using it, you must make sure that there are two conditions.

1- your project is built in the target folder (Spring Tool Suite)

2- you have access to tomcat via ssh

code example: (v_: prefix, which is a variable (configurable))

 rsync -avz v_your_project_in_target root@v _ip:v_tomcat_name/webapps/v_project_name 

(Second access)

0
source

Source: https://habr.com/ru/post/954345/


All Articles