3.pom文件详解

文章详细介绍了Maven项目的POM配置,包括模型版本、父模块、模块、坐标、打包方式等核心元素。此外,还涵盖了依赖管理和构建配置,如插件版本、资源过滤以及环境配置profil。文章强调了这些配置在项目管理和构建过程中的重要性。
摘要由CSDN通过智能技术生成

1.pom配置

<?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">
  <!--maven的版本号-->
  <modelVersion>4.0.0</modelVersion>
  
  <!--通常用于子模块对父模块pom的继承-->
  <parent>
  	<groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.4</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <!--用来聚合运行Maven项目,指定多个模块一起编译-->
  <modules>
  	<module></module>
  </modules>
  
  <!--坐标-->
  <!--公司网址反写+项目名-->
  <groupId>com.leichuangkj.topicbet</groupId>
  <!--项目名+模块名-->
  <artifactId>football</artifactId>
  <!--快照版本-->
  <version>1.0-SNAPSHOT</version>
  
  <!--打包方式-->
  <!--打包方式,默认是jar,可选war、zip、pom-->
  <packaging>jar</packaging>
  
  <!--项目名称-->
  <name>topicbet football</name>
  
  <!--项目地址-->
  <url>http://www.example.com</url>
  
  <!--项目描述-->
  <description>足球竞猜</description>
  
  <!--开发人员列表-->
  <developers>
  	<developer>Steven</developer>
  </developers>

  <!--属性-->
  <properties>
	<log4j.version>1.2.17</log4j.version>
  </properties>

  <!--依赖列表,整个项目都会包含-->
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
    </dependency>
  </dependencies>
  
  <!--依赖的管理,作用主要定义在父模块中,对子模块进行管理-->
  <dependencyManagement>
	<dependencies>
		<!-- 日志框架 -->
		<dependency>
		   <groupId>log4j</groupId>
		   <artifactId>log4j</artifactId>
		   <version>${log4j.version}</version>
		</dependency>
	</dependencies>
  </dependencyManagement>

  <!--项目级别的构建,基础配置-->
  <build>
    <finalName>demo</finalName>
    <pluginManagement>
      <!--插件列表-->
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.0.1</version>
          <executions>
            <execution>
              <phase>package</phase>
              <goals>
                <goal>jar-no-fork</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  <!--环境隔离配置-->
  <profiles>
    <profile>
      <id>dev</id>
      <activation>
        <!--默认激活的环境-->
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <deploy.type>dev</deploy.type>
      </properties>
    </profile>
  </profiles>
</project>

2.build配置项

<build>
  <defaultGoal>install</defaultGoal>
  <directory>${basedir}/target</directory>
  <finalName>${artifactId}-${version}</finalName>
  <resources>
    <resource>
      <targetPath>META-INF/plexus</targetPath>
       <!--是否使用过滤器-->
      <filtering>false</filtering>
      <directory>${basedir}/src/main/plexus</directory>
      <includes>
        <include>configuration.xml</include>
      </includes>
      <excludes>
        <exclude>**/*.properties</exclude>
      </excludes>
    </resource>
  </resources>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <version>2.0</version>
      <!--是否使用扩展-->
      <extensions>false</extensions> 
      <!--是否可继承-->
      <inherited>true</inherited> 
      <!--当前插件的配置-->
      <configuration> 
        <classifier>test</classifier>
      </configuration>
    </plugin>
  </plugins>
  <!--通过扩展来修改插件的行 -->
  <extensions> 
    <extension>
      <groupId>org.apache.maven.wagon</groupId>
      <artifactId>wagon-ftp</artifactId>
      <version>1.0-alpha-3</version>
    </extension>
  </extensions>
</build>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值