catalogue
1: Basic concepts of maven project
2: Configuration of maven project on idea software
1: Basic concepts of maven project
Maven project object model (POM) can manage the construction, reporting and file of Project management tools Software.
In addition to program building capabilities, Maven also provides advanced project management tools. Because Maven's default build rules are highly reusable, simple projects can often be built with twoorthree lines of Maven build scripts. Due to Maven's project oriented approach, many Apache Jakarta projects use Maven when issuing documents, and the proportion of company projects adopting Maven continues to grow.
The word Maven comes from Yiddish (Jewish), which means the accumulation of knowledge. It was originally used in the Jakata Turbine project to simplify the construction process. At that time, there were some projects (with their own Ant build files), with only minor differences, and JAR files were all created by CVS To maintain. So we hope to have a standardized way to build projects, a clear way to define the composition of projects, an easy way to publish project information, and a simple way to share JARs in multiple projects.
Maven can easily help you manage project reports, generate sites, manage JAR files, and so on
Role: complete the relevant operations of the project, such as compilation, construction, unit testing, installation, website generation and Maven based deployment project.
2: Configuration of maven project on idea software
1. Create a basic maven project
2. Initial appearance of maven project after creation
3. Right click, click new, and then click Directory to create the basic structure of the project
4. Write pom.xml file
<?xml version="1.0" encoding="UTF-8"?> <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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.zking</groupId> <artifactId>maven01</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>maven01 Maven Webapp</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com</url> <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> <!--junit--> <junit.version>4.13</junit.version> <!--servlet--> <servlet.version>4.0.1</servlet.version> </properties> <dependencies> <!-- junit--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <!-- servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>${servlet.version}</version> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>maven01</finalName> <plugins> <!--The first step is to configure maven-compiler-plugin plug-in unit--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> </plugins> </build> </project>
5. Set the version of web.xml, and change version 2.3 to version 3.0
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>Archetype Created Web Application</display-name> </web-app>
6. Write the index.jsp page and test it to see whether the maven project is successfully configured
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2022/7/18 0018 Time: 22:56 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <h2>Hello wrold</h2> </body> </html>
7. Effect display
OK, maven project is successfully configured on idea software. If you configure it several times, you will be proficient in it