maven POM总结

可继承的字段

version

property

 其他占坑:

parent

import

scope   Dependency_Management中的scope是可以被继承的,http://maven.apache.org/pom.html#Dependency_Management 

classifier源码上传

用于区分源码, doc, bin等文件

单独上传到仓库时要加这个参数

mvn deploy:deploy-file -Dmaven.test.skip=true -DgroupId=com.demo.test  -DartifactId=mvc -Dversion=1.0.0-SNAPSHOT -Dpackaging=jar

-Dfile=D:ideProjectdemo-1.0.0.-SNAPSHOT-sources.jar -Dclassifier=sources  -Durl=http://{ip}:{port}/repository/maven-snapshots/

-DrepositoryId=server_id

注意文件名是-sources, 不是-source

 

 下载sources文件方法  

mvn dependency:sources -DdownloadSources=true

 可以查看下载路径, https://repo.rdc.aliyun.com/repository/109514-release-nbjZwi/com/alibaba/taobao/taobao-sdk/20200414/taobao-sdk-20200414-sources.jar

 如果本地目录已经存在此文件,删除后重新执行上面的命令。

name 不可继承

artifactId 不可继承 , 确定打包的最终名称。 这个属性值可以和name的属性不一样。。

 

pluginManager

dependencyManagement

deploy

build

plugin target goal

强制idea刷新POM, 加-U参数

aliyun镜像配置

https://rdc.console.aliyun.com下载settings.xml文件

集成测试的标准目录

https://www.baeldung.com/maven-integration-test

src/main/java

src/test/java

src/intergationtest/java

集成测试的目录是和test分开的,方便mvn pom配置, 使用的插件有failsafe(要求后缀是*IT.java), Surefire

如果放在src/test/it,  需要在compile期间添加这个目录作为test root, 编译后仍然放在test-classes

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <id>add-integration-test-source</id>
            <phase>generate-test-sources</phase>
            <goals>
                <goal>add-test-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>src/integration-test/java</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>
还有个添加resources的配置<goal>add-test-resource</goal>

 

原文地址:https://www.cnblogs.com/yszzu/p/9248959.html