Download and install Tomcat in macOS sisierra Version 10.12.6 and configure Tomcat and create Web projects in InterlliJ IDEA 2017.2,
1. Download and install Tomcat
1. Official website (http://tomcat.apache.org/) download Tomcat 9.0 Core: zip package;
2. Unzip the package to the specified folder to complete the installation;
3. test whether the installation is successful.
Use terminal to switch to the bin directory of the folder
Get the execution permission $ chmod + x *. sh
Start Tomcat $./startup. sh
Enter localhost: 8080 in the browser. If it is displayed as a piece, the installation is successful.
Disable Tomcat $./shutdown. sh
4. installation directory description
Bin -- Tomcat execution Script directory
Conf -- Tomcat configuration file
Lib -- the library file (JARS) required for running Tomcat)
Logs -- the LOG file during Tomcat execution
Temp -- Tomcat temporary file storage directory
Webapps -- Tomcat's main Web publishing directory (which stores our own JSP, SERVLET, and Class)
Work -- Tomcat's working directory. Tomcat puts the Java and class files translated from JSP files here.
Ii. Configure Tomcat and create Web projects in InterlliJ IDEA 2017.2 Environment
1. Tomcat configuration
① Configure-> Preferences-> Build, Execution, Deployment-> Application Servers
② Add application server-> Tomcat Server
Note: This operation solves the problem where the Tomcat Server cannot be found during normal Web Project Creation.
2. Create a Web Project
① Create New Project --> Java Enterprise --> Web Application (3.1) --> check "Create web. xml" --> next
② Create a project name and path --> Finish
③Create two folders under the web/WEB-INF: classes and lib
Classes is used to store the class files output after compilation, and lib is used to store third-party jar packages.
④ Configure the folder path
File-> Project Structure (shortcut: Ctrl + Shift + Alt + S)-> select Module: select Paths-> select "Use module compile output path"-> select the classes folder created in both the Output path and Test output path.
Then select Dependencies --> click "+" at the bottom-> select "Jars or Directories" -->-> select the created lib folder
--> Select "jar directory" --> then return an OK
⑤ In the upper-right corner, you can select the default configuration or modify the Tomcat Server configuration (name, path, default browser, etc.).
Add Tomcat
Edit deployments --> "+" in the upper left corner --> Tomcat Server --> Local
⑥ Running project
Click debug or run (first debug control + alt + D)
It is shown as follows, proving that the creation is successful
To stop running, press command + F2