在創(chuàng)建Java庫(kù)后嗅剖,上傳到遠(yuǎn)程倉(cāng)庫(kù)時(shí)忆蚀,最好帶上源碼包方便使用的人理解矾利,不然功能只完成了一半,東西給別人用了馋袜,但是別人不知道怎么用男旗。
1 添加配置
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- explicitly define maven-deploy-plugin after other to force exec order -->
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals><goal>deploy</goal></goals>
</execution>
</executions>
</plugin>
2 mvn clean install或者mvn clean deploy
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ starterdemo ---
[INFO] Installing D:\code\fordemo\starterdemo\target\starterdemo-0.0.1-SNAPSHOT.jar to C:\Users\aihe\.m2\repository\me\aihe\starterdemo\0.0.1-SNAPSHOT\starterdemo-0.0.
1-SNAPSHOT.jar
[INFO] Installing D:\code\fordemo\starterdemo\pom.xml to C:\Users\aihe\.m2\repository\me\aihe\starterdemo\0.0.1-SNAPSHOT\starterdemo-0.0.1-SNAPSHOT.pom
[INFO] Installing D:\code\fordemo\starterdemo\target\starterdemo-0.0.1-SNAPSHOT-sources.jar to C:\Users\aihe\.m2\repository\me\aihe\starterdemo\0.0.1-SNAPSHOT\starterd
emo-0.0.1-SNAPSHOT-sources.jar
[INFO] ------------------------------------------------------------------------
3 查看內(nèi)容
image.png