How to Fix Duplicate Project Loading When Configuring Tomcat Virtual Hosts
When configuring Tomcat Host, you often encounter projects loading multiple times. Here is the solution I have summarized:
It is generally caused by defining virtual directories, such as having both appBase and docBase pointing to the same directory.
The difference between appBase and docBase: appBase specifies the directory of the virtual host, which can be an absolute or relative directory. If not specified, it defaults to the webapps directory. docBase specifies the file path of the Web application. It can be given as an absolute path or a relative path relative to the Host’s appBase attribute.
For example, my previous configuration file:
Then the docBase=“webapps/pc” path below pointed to a directory under webapps. The content in the www folder was loaded earlier, and then loaded again later, causing duplicate loading. Try changing it to the following.
Below is the new virtual directory configuration:

…
In the above snippet, I pointed the virtual directory to a folder under www, meaning the path loaded by the virtual directory cannot be the same as the root directory, otherwise it will cause duplicate loading.