- 在要打包的项目的pom.xml里面配置插件,注意,如果是多项目工程,需要在要打包的项目下添加,不能在父项目上添加
添加打包源码配置
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.0</version>
<!-- 绑定source插件到Maven的生命周期,并在生命周期后执行绑定的source的goal -->
<executions>
<execution>
<!-- 绑定source插件到Maven的生命周期 -->
<phase>compile</phase>
<!--在生命周期后执行绑定的source插件的goals -->
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
添加完之后,我们就可以用命令打包了,在项目下
打包jar和source.jar
mvn install
仅仅打包source.jar
mvn source:jar
- 上传到私服
在pom.xml中添加
<distributionManagement>
<repository>
<id>rdc-releases</id>
<name>rdc-releases</name>
<url>https://repo.rdc.aliyun.com/repository/10919-release-S3E5lq/</url>
</repository>
<snapshotRepository>
<id>rdc-snapshots</id>
<name>rdc-snapshots</name>
<url>https://repo.rdc.aliyun.com/repository/10919-snapshot-wGqfKk/</url>
</snapshotRepository>
</distributionManagement>
release是正式的地址,snapshots是开发测试用的,如果有用户名密码的话,需要到maven的setting.xml中配置用户名和密码
<!-- 阿里云私服认证 -->
<server>
<id>rdc-releases</id>
<username>NKDdZq</username>
<password>oKsehjL1j1</password>
</server>
<server>
<id>rdc-snapshots</id>
<username>NKDdZq</username>
<password>oKsehjL1j1</password>
</server>
id就对应上面pom.xml中配置的id
最后上传jar到私服
mvn deploy