Eclipse Oxygen创建maven web项目(二)
配置项目依赖库及第三方工具。
如示例的pom.xml
<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>公司名称</groupId> <artifactId>项目名称</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>项目名称</name> <!-- 经常更新的库的版本信息配置 --> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <struts2.version>2.5.16</struts2.version> <log4j2.version>2.11.0</log4j2.version> <jetty-plugin.version>9.4.11.v20180605</jetty-plugin.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <!-- 作用范围test意味着发布打包的时候会忽略掉 --> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>${struts2.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>${log4j2.version}</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-tiles-plugin</artifactId> <version>${struts2.version}</version> </dependency> <!-- <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-convention-plugin</artifactId> <version>${struts2.version}</version> </dependency> --> </dependencies> <!-- 如果引用库的依赖库有多个相同库的不通版本,可以在这里明确使用这一个版本 --> <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>${log4j2.version}</version> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.10.4</version> <configuration> <additionalparam>-Xdoclint:none</additionalparam> </configuration> </plugin> <!-- 插件jetty的配置信息,然后可以愉快的使用mvn jetty:run命令运行测试了--> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty-plugin.version}</version> <configuration> <webApp> <contextPath>/${project.artifactId}</contextPath> </webApp> <stopKey>CTRL+C</stopKey> <stopPort>8999</stopPort> <scanIntervalSeconds>10</scanIntervalSeconds> </configuration> </plugin> </plugins> </build> </project>
上善若水,水利万物而不争。