export
How to configure Maven, tomcat and the process of creating a new project in idea
Maven configuration
maven can be used for
(1) Project management;
(2) Dependency management;
1. Close the project first, and then the following interface will appear
2. Set the following configuration [core]
3. Parameter analysis
4. High version idea configuration method
Import package to refresh
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.22</version> </dependency>
Tomcat configuration
0. Pre-work: Configure JAVA_HOME
1. Modify port and encoding gbk
2. Service startup and shutdown
startup.bat start
shutdown.bat shutdown
3. Browser input for access
http://127.0.0.1:10081
Create a new project in idea
4. Create a new project in IDEA
(1) Configure Tomcat service
Select the installation location of tomcat
After the configuration is successful, click apply
(2) Create a new project
(3) The following interface appears after running, successful
5. Create a new project in general way
(1) Choose maven to create a new project, where Archetype chooses maven’s webapp
(2) Configure the pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.tianju</groupId> <artifactId>javaweb0604</artifactId> <!-- The packaging method, the default is jar, if it is a web project, you need to write war--> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <!-- This jar package does not participate in running Tomcat, but it should be used during development --> <scope>provided</scope> </dependency> </dependencies> </project>
Other commonly used configurations
<dependency> <!-- lombok--> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.22</version> </dependency> <dependency> <!-- io stream --> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.5</version> </dependency> <dependency> <!-- Ali's database management tool --> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.2.16</version> </dependency> <dependency> <!-- sql connection tool --> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.20</version> </dependency> <dependency> <!-- jdbc connection database tool --> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.2.22.RELEASE</version> </dependency> <dependency> <!-- junit unit testing tool --> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>RELEASE</version> <scope>compile</scope> </dependency>
(3) Configure the web.xml file
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> </web-app>
(4) Create a new file
Right-click to create a new file under src
(5) Configure the running environment
select the expanded
(6) Run
Summary
1. The role of maven, its configuration, and the method of creating a new maven project;
2. Tomcat configuration, port number change, Chinese garbled solution;
3. Two ways to create a new web project in idea and the operation process;