The way I do it now:
1. When configuring Tomcat in Eclipse, choose Create context file instead of Server.xml, the benefit is that the file can be arbitrarily named, consistent with the virtual directory (that is, the attribute path in XML). When Tomcat loads a project, it scans all the XML files in the Conf\catalina\localhost directory and then loads them according to the configuration.
The XML file in the Conf\catalina\localhost directory. In general, a project corresponds to an XML file, and if you want to load only one project, change the file to non-XML.
The contents of the XML in the context file:
<context privileged= "true" antiresourcelocking= "false" Path= "/myapp" reloadable= "true" docbase= "D:\ECP_workspace \myapp\applications " />
2. Transfer the classes folder from the build folder to the Web-inf. On the project, right-click Build path--〉configure Build Path, set the default output folder. At the same time, the Lib is also placed under the Web-inf, tomcat loading can be loaded together.
The corresponding project directory structure, as follows:
Reference:
Three ways to deploy projects in Java Web development tomcat
How to quickly develop an SSH framework project
How common Java projects in eclipse are deployed to Tomcat