maven 配置文件详解

来源:互联网 发布:xbrower连接linux桌面 编辑:程序博客网 时间:2024/06/08 08:53

maven配置文件里面参数多种多样,下面介绍的是,我已经使用并且明白的配置



<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion><!-- maven版本 -->
  <parent>
    <groupId>sx-m</groupId><!-- 父类项目组id -->
    <artifactId>USER_CENTER_M</artifactId><!-- 父类项目id -->
    <version>0.0.1</version><!-- 父类项目版本号  -->
  </parent>
  <groupId>sx-m</groupId><!-- 项目组id -->
  <artifactId>sx-manager-provider</artifactId><!-- 项目id -->
  <version>0.0.1</version><!-- 项目版本号  -->
  <name>sx-manager-provider</name><!-- 项目名称 -->
  <url>http://maven.apache.org</url>
  <properties><!-- properties 属性配置-->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- 指定 maven编译的jdk版本,也可以在build里面配置,这里效果最佳->

    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>


  </properties>
  <dependencies>
  <dependency><!-- 对别的包的依赖-->
 <groupId>sx-m</groupId>
 <artifactId>sx-manager-api</artifactId>
 <version>0.0.1</version>
 <optional>true</optional><!-- 别的项目引入此项目时,不会引入sx-manage-api引入 -->
</dependency>
<dependency><!-- 对别的包的依赖-->
 <groupId>sx</groupId>
 <artifactId>sx-common</artifactId>
 <version>0.0.1</version>
  <exclusions><!-- 排除common所有依赖的包的包 -->
<exclusion>
 <groupId>*</groupId>
 <artifactId>*</artifactId>
</exclusion>
 </exclusions>
</dependency>
  </dependencies>


  <build>
<finalName>sx-user-cernter-provider</finalName><!-- 项目打包时的名字 -->
<sourceDirectory>src/main/java</sourceDirectory><!-- 项目的文件来源目录 -->
<resources>
<resource><!-- 配置需要过滤掉的文件 -->
<targetPath>${project.build.directory}/classes/META-INF/spring</targetPath>
<directory>src/main/resources/META-INF/spring</directory>
<filtering>true</filtering>
<excludes>
<exclude>*.xml</exclude>
<exclude>*.properties</exclude>
</excludes>
</resource>
<resource><!-- 配置需要打入包内的文件 -->
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>


<plugins>
<!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classesDirectory>target/classes/</classesDirectory>
<excludes>
<exclude>**/provider.properties</exclude>
<exclude>*.properties</exclude>
<exclude>**/datasource/**</exclude>
<exclude>*.xml</exclude>
</excludes>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
<!-- 拷贝依赖的jar包到lib目录 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
            <plugin><!-- 打包时,打成什么样的包及一些其他配置 -->
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptor>src/main/assembly/assembly.xml</descriptor>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
</plugins>
</build>
</project>

0 0
原创粉丝点击