把本身的項目發佈到maven倉庫並在maven和gradle中開始使用html
上一條博客中提到的日誌打印項目總算是維護的差很少了, 不過如今使用它仍是打成jar包放到其餘項目內, 因此決定把項目傳到maven倉庫內, 使用時只須要配置一下便可了maven
我使用的是阿里雲的maven倉庫服務, 如何購買阿里雲倉庫這裏就很少說了, 去阿里雲上找很容易找到gradle
1. 修改maven配置文件conf/settings.xmlui
<servers> <server> <id>rdc-releases</id> <username>阿里倉庫帳號</username> <password>密碼</password> </server> <server> <id>rdc-snapshots</id> <username>阿里倉庫帳號</username> <password>密碼</password> </server> </servers>
<mirrors> <mirror> <id>mirror</id> <mirrorOf>!rdc-releases,!rdc-snapshots</mirrorOf> <name>mirror</name> <url>https://maven.aliyun.com/nexus/content/groups/public</url> </mirror> </mirrors>
<profiles> <profile> <id>rdc-private-repo</id> <repositories> <repository> <id>rdc-releases</id> <url>https://repo.rdc.aliyun.com/repository/119569-release-xxxx/</url> </repository> <repository> <id>rdc-snapshots</id> <url>https://repo.rdc.aliyun.com/repository/119569-snapshot-xxxx/</url> </repository> </repositories> </profile>
<groupId>com.xxx.common</groupId> <artifactId>xxxx-log</artifactId> <version>1.0</version> <packaging>jar</packaging>
有一點要注意, 項目的pom.xml文件呢不能有<build>標籤, 否則下一步會失敗, 並且正式版的版本號內不能帶有SNAPSHOT阿里雲
在pom.xml文件中右擊,run As – Maven build … 打開以下的框。
在 Goal輸入以下命令:url
上傳成功後如圖:spa
maven:.net
首先在settings.xml中添加配置:3d
<servers> <server> <id>rdc-releases</id> <username>帳號</username> <password>******</password> </server> <server> <id>rdc-snapshots</id> <username>帳號</username> <password>******</password> </server> <profile> <id>rdc-private-repo</id> <repositories> <repository> <id>rdc-releases</id> <url>https://repo.rdc.aliyun.com/repository/119569-release-xxx/</url> </repository> <repository> <id>rdc-snapshots</id> <url>https://repo.rdc.aliyun.com/repository/119569-snapshot-xxx/</url> </repository> </repositories> </profile>
在項目的pom.xml文件中加入依賴項日誌
<dependency> <groupId>剛纔上傳時的分組id</groupId> <artifactId>剛纔上傳時的項目id</artifactId> <version>1.0</version> </dependency>
gradle:
在build.gradle文件內加入配置:
allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/public' } maven { credentials { username '帳號' password '******' } url 'https://repo.rdc.aliyun.com/repository/119569-release-xxx/' } maven { credentials { username '帳號' password '******' } url 'https://repo.rdc.aliyun.com/repository/119569-snapshot-xxx/' } } }
在build.gradle文件內加入依賴項
compile group: '剛纔上傳時的分組id', name: '剛纔上傳時的項目id', version: '1.0'
參考文章:
http://www.javashuo.com/article/p-uytoscfg-kv.html
https://blog.csdn.net/loveshunyi/article/details/88813433
本文連接: