Create and run web projects in IntelliJ IDEA

[1. Create a project]

Give a name and click finish

2,

 [3. Set the output and dependency directories ]

 Right-click the folder WE-INF, create two folders under web/WEB-INF: classes and lib, and set the output path

classes are used to store the compiled class files, and lib is used to store third-party jar packages.

File -> Project Structure (shortcut: Ctrl + Shift + Alt + S) -> select Module:

Select Paths -> select "Use module compile output path" -> select the classes folder just created for both Output path and Test output path.

Then select Dependencies -> select Module SDK as 1.7 -> click the "+" sign on the right -> select 1 "Jars or Directories" 

check

[4, configure the tomcat container]

Open the menu Run -> select Edit Configuration 

Click the "+" sign -> select "Tomcat Server" -> select "Local"

Enter a new service name in "Name", click "Configure..." behind "Application server", the Tomcat Server window will pop up, select the locally installed Tomcat directory -> OK 

To select tomcat and path, you   need to install tomcat

In the "Server" palette, uncheck "After launch", set "HTTP port" and "JMX port" (the default values ​​are fine), click Apply -> OK, and the Tomcat configuration is complete.

[5. Deploy and run the project in Tomcat  ]

Run -> Edit Configurations, enter the "Run/Debug Configurations" window -> select the Tomcat container you just created -> select Deployment -> click the "+" sign on the right -> select Artifact

-> Select the web project -> Application context can fill in "/firstweb" (in fact, it can be left blank~~) -> OK

After confirming, you can run

Guess you like

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