IDEA creates a traditional JAVA WEB project (built with maven)
Method 1
File --> NEW --> Project --> Java (check Web Application)
Method 2
File --> NEW --> Project --> Java Enterprise (check Web Application)
IDEA deploys JAVA WEB project
IDEA does not place the project in tomcat's webapp directory, but the project is still in the source project directory. IDEA adopts a non-invasive Tomcat project deployment method (no modification of any tomcat files) <virtual directory method>
After IDEA starts Tomcat, the corresponding projectName directory will be created in the ${user.home}/.IntelliJIdea/system/tomcat directory, and copy 3 directories to the ${user.home}/.IntelliJIdea/system/tomcat/projectName directory. This will cause each project to correspond to three directories: conf, logs, and work: conf, logs, andIn the conf/Catalina/localhost/ROOT.xml configuration file, the configuration associated with the JAVAWEB project is as follows:
<?xml version="1.0" encoding="UTF-8"?><Context path="" docBase="G:/work/java/je/out/artifacts/je_war_exploded" />
conf/Catalina/localhost/ROOT.xml configuration file properties
<?xml version="1.0" encoding="UTF-8"?><Context path="" docBase="G:/work/java/je/out/artifacts/je_war_exploded" />
path
Set the URL to access the web application portal (set URL entry routing)
docBase
Set the project path of the web application
className
Specify the Java class name that implements the Context interface
reloadable
If set to true, tomcat will automatically reload according to WEB-INF directory changes. It will be set to true during general development/debugging, and the official production environment will be set to false.
Virtual Directory
effect:
1. When the host:port in the URL is the same, multiple projects can be deployed (usually this is rarely used)
For example:
http://localhost:8080/
http://localhost:8080/manager
http://localhost:8080/admin
2. Separate the project storage location from webapps in the root directory of tomcat, which is safer
Configuration method one
Create: tomcat root directory /conf/Catalina/domain name/test.xml file
content:
<?xml version="1.0" encoding="UTF-8"?> <Context docBase="G:/work/java/je/out/artifacts/je_war_exploded" />
Visit url: http://localhost:8080/test
Virtual Host
Function: A server binds multiple domain names, one domain name corresponds to one project (mostly) or one domain name corresponds to multiple projects (very rare)
Configuration method
Add the following code to the tomcat root directory /conf/server.xml file:
<Host name="www.jalja2.org" appBase="E:/Learning/activeMq/app2" unpackWARs="true" autoDeploy="true"></Host>
Summarize
The above is the method of IDEA deploying JavaWeb projects to Tomcat server introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!