Java 20 maven项目基本配置

发布时间 2023-09-04 11:21:18作者: OYそ

 pom.xml

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <!--
<project > :文件的根节点
<modelversion > : 使用的对象模型版本
<groupld > :项目名称,一般写项目的域名
<artifactld > :模块名称,子项目名或模块名称
<version > :产品的版本号
<packaging > :打包类型,jar、 war、pom等
<name> :项目的显示名
<properties> : jdk编译版本或常量值
<dependencies> :项目依赖构件的坐标
<build> :项目编译、运行插件
-->

<modelVersion>4.0.0</modelVersion>
<!--坐标-->
<groupId>com.example</groupId>
<artifactId>JakartaEE01</artifactId>
<version>1.0-SNAPSHOT</version>
<name>JakartaEE01</name> <packaging>war</packaging><!--无则默认打包成.jar,有父子关系时默认改为war pom是供别人继承的,继承时要install一下导到本地仓库--> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> <junit.version>5.7.1</junit.version> </properties> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope><!--provided编译时需要,类似于jdk 运行时不需要,如servlet包 不打包进去 compile缺省值,适用于所有阶段,会打包进项目 runtime 编译不需要,运行要 ,如mysql的驱动jar包 会打包进项目 test测试时需要,发布时不要,如junit包 ,不会打包进项目 --> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.13</version> <scope>compile</scope> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.49</version> <scope>runtime</scope> </dependency> </dependencies> <build> <finalName>aaaa</finalName><!--最终打包的名字,可不写--> <plugins> <plugin><!--打包插件--> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.3.1</version> </plugin> </plugins> </build> </project>