Maven 简介
Maven 是一个项目管理和构建自动化工具,可以用于构建和管理任何基于Java的项目。它基于项目对象模型(POM)的概念来管理项目的构建、报告和文档。
Maven 使用约定优于配置的原则,它要求在没有定制之前,所有的项目都有如下的结构:
目录 | 目的 |
---|
${basedir} | 存放pom.xml和所有的子目录 |
${basedir}/src/main/java | 项目的java源代码 |
${basedir}/src/main/resources | 项目的资源,比如说property文件,springmvc.xml |
${basedir}/src/test/java | 项目的测试类,比如说Junit代码 |
${basedir}/src/test/resources | 测试用用的资源 |
${basedir}/src/main/webapp/WEB-INF | web应用文件目录,web项目的信息,比如存放web.xml、本地图片、jsp视图页面 |
${basedir}/target | 打包输出目录 |
${basedir}/target/classes | 编译输出目录 |
${basedir}/target/test-classes | 测试编译输出目录 |
pom.xml 文件简析
该pom.xml文件来自spring-boot-plus,做了简化处理。
<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>io.geekidea</groupId> <artifactId>spring-boot-plus</artifactId> <version>1.2.1.RELEASE</version> <packaging>jar</packaging>
<name>spring-boot-plus</name> <description>spring-boot-plus Project</description> <url>https://github.com/geekideaio/spring-boot-plus</url> <licenses> <license> <name>The Apache License, Version 2.0</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> </license> </licenses> <developers> <developer> <id>spring-boot-plus</id> <name>geekidea</name> <email>geekidea@qq.com</email> </developer> </developers>
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project-parent.version>${parent.version}</project-parent.version> <java.version>1.8</java.version> <spring-boot.version>2.1.7.RELEASE</spring-boot.version> <mybatis-plus-boot-starter.version>3.1.2</mybatis-plus-boot-starter.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> </properties>
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>***</groupId> <artifactId>***</artifactId> </exclusion> </exclusions> </dependency> </dependencies>
<profiles> <profile> <id>local</id> <properties> <profileActive>local</profileActive> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>dev</id> <properties> <profileActive>dev</profileActive> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> <profile> <id>test</id> <properties> <profileActive>test</profileActive> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> <profile> <id>uat</id> <properties> <profileActive>uat</profileActive> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> <profile> <id>prod</id> <properties> <profileActive>prod</profileActive> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> </profiles>
</project>
|