Regarding the packaging and deployment of the Maven project, I use the Eclipse editor here to make a simple record.
Practical environment
Operating system: Windows
IDE: Eclipse
Packaging and deployment process
1 Project package
1.1 Right-click the item you need to package and click Maven clean as shown in the figure. Here, Maven will clear all the packaging information for this project before.
1.2 After completing the Maven clean operation, the following information will appear in the eclipse console.
1.3 Then we right-click the required package project and click Maven build as shown in the figure
1.4 In the pop-up interface, perform the operation as shown in the figure below.
Enter -X package in the "Goals" input box, and check Update Snapshots and Skip Tests option boxes below.
1.5 The following results appear, which means that the packaging is successful.
1.6 Refresh our project, and we can find the war package we packed in the project target directory.
2 Project deployment
2.1 Place the above packaged war package in our tomcat webapps directory. As shown in the figure.
2.2 Modify the configuration file server.xml in the conf directory in tomcat, find the Host tag in the configuration file, and add the following content to it. The relative path is used here, and the value of doBase property is the name of war package we are calling (as for why we need to add this step, we will explain it later).
Copy the code code as follows:<Context docBase="analysis-tool-web-1.0-SNAPSHOT" path="/" reloadable="true" privileged="true"/>
2.3 Enter the bin directory of tomcat and click startup.bat to start our tomcat. The following results are displayed to indicate that the deployment is successful.
2.4 At this time, we open the browser and enter localhost:8080 , and we successfully access our homepage.
illustrate
As mentioned above, add the following to the server.xml configuration file in the conf directory in our tomcat.
Copy the code code as follows:<Context docBase="analysis-tool-web-1.0-SNAPSHOT" path="/" reloadable="true" privileged="true"/>
Let’s comment out the original content first and restart to see what problems will occur.
After commenting out, restart our tomcat and access localhost:8080 in your browser.
You will find that our project cannot be requested at this time. In this case, add our project name to the access path and try again, and visit http://localhost:8080/analysis-tool-web-1.0-SNAPSHOT/login (all resources and requests of the project are in analysis-tool-web-1.0-SNAPSHOT directory).
There is basically no problem at this point as before. The problem is that after we click to log in, the subsequent request path changes. I tried to log in and see the jump path after login.
Here, our project path /analysis-tool-web-1.0-SNAPSHOT tool-web-1.0-SNAPSHOT is defaulted, and the current project resources and requests are all in analysis-tool-web-1.0-SNAPSHOT folder. The request jumps directly to / , resulting in a 404 error for the request that cannot find the resource. The above content is configured in server.xml mainly to set the relative path of the resource for accessing the project.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.