把本身的项目发布到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
本文连接: