When the project is deployed to tomcat in eclipse, it is deployed to the wtpwebapps folder

Background : Create a new Dynamic Web Project in eclipse, configure the local tomcat and write the code and select Run on Server, but after running, it is found that the webapps in the tomcat installation directory does not have the project name created. So where did the deployment go? Isn't it said that the good webapps directory is the directory where the application is stored?


Impact : Apparently the project is not automatically deployed to Tomcat's webapps but is deployed in another container. Enter http://localhost:8080 /webDemo/login.jsp in the built-in browser to open normally. But when I open http://localhost:8080 on an external browser, the expected kitten screen does not appear.

Reason : The reason eclipse is not like MyEclipse, which deploys the project to the webapps in the tomcat installation directory by default, but the default deployment to .metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps in the working directory, tmp1 The folder contains information about the project.


Difference : The difference between the wtpwebapps folder and the webapps folder under tomcat is that

(1) webapps: tomcat default deployment path

(2) wtpwebapps: eclipse default deployment path
Under the tomcat configuration file server.xml
<Context docBase="TestByHuangyu" path="/TestByHuangyu" reloadable="true" source="org.eclipse.jst.jee.server:TestByHuangyu"/></Host>
is to point to the root directory
path of your program and access it program name

The docbase tag attribute in the context is automatically generated, eclipse is deployed to wtpwebapps by default, and tomcat is deployed to webapps by default


If you want to be in the webapps directory every time you deploy to tomcat

solution:

Modify In order to deploy the project to the webapps in the tomcat installation directory by default, show view—>servers—> find the tomcat that needs to be modified—> right click

①Stop the Tomcat server in eclipse (stop)
②Delete the project deployed in the container (add and remove)
③Clear the relevant data of the container (clean)
④Open the modification interface of tomcat (open)
⑤Find the servers location and select the second one (User tomcat Installation)
⑥ Modify the deploy path to webapps
⑦ Save and close

①②③ must be operated, otherwise the following steps will be grayed out and cannot be operated.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325989273&siteId=291194637