主题
快速开始
1.申请使用
(1)进入研发云>组件广场>二方库页面,点击可申请的二方库
,搜索二方库ctzhejiang_pubinfo-lshare-maven-mc
,点击申请使用
。
(2)选择自己的项目,填写使用原因,选择审核人后,发起使用申请。
2.项目制品引用
二方库使用申请审批通过后,进入研发云对应项目的项目设置>制品
页面,创建maven类型的虚拟制品库(如果项目已有虚拟制品库,编辑即可),共享库中选择ctzhejiang_pubinfo-lshare-maven-mc
, 本地仓库和公共虚拟库按需选择即可。
3.maven配置
虚拟制品库创建完成后,需要配置配置对应的制品库地址,分为pom文件配置及maven setting配置两种方式,示例如下:
(1)pom文件配置(推荐)
在项目的根pom文件中,加入如下配置,并替换 release制品地址
和 snapshot制品地址
:
xml
<repositories>
<repository>
<id>artifact-srdcloud-cn-virtual-release</id>
<url>release制品地址</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>artifact-srdcloud-cn-virtual-snapshot</id>
<url>snapshot制品地址</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
注意
如果只有release制品地址(或snapshot制品地址),两个地址填写一样即可。
在maven的setting文件中,加入如下配置,并替换用户账号
和制品库的API Key
:
xml
<servers>
<server>
<id>artifact-srdcloud-cn-virtual-release</id>
<username>用户账号</username>
<password>制品库的API Key</password>
</server>
<server>
<id>artifact-srdcloud-cn-virtual-snapshot</id>
<username>用户账号</username>
<password>制品库的API Key</password>
</server>
</servers>
注意:
server的id要与pom中的repository的id保持一致。
同一个制品库集群,API Key是同一个,不同的制品库集群地址,可能需要生成新的API Key。
不同项目代码中,同一个制品库集群,pom中repository的id可以配置为同一个,这样setting中同一个制品库集群的server配置可以共用。
(2)maven setting文件配置
在maven的setting文件中,加入如下配置,并替换用户账号
、制品库的API Key
、release制品地址
和 snapshot制品地址
。
xml
<servers>
<server>
<username>用户账号</username>
<password>制品库的API Key</password>
<id>central</id>
</server>
<server>
<username>用户账号</username>
<password>制品库的API Key</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>制品库名称</name>
<url>release制品地址</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>制品库名称</name>
<url>snapshot制品地址</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>制品库名称</name>
<url>release制品地址</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>制品库名称</name>
<url>snapshot制品地址</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
注意
如果多个项目的制品库都需要在setting中配置,注意repository的id不要重复。 如果项目较多,此方式会频繁修改setting文件。
4.组件使用
1、项目的根pom中,指定parent为cn.zjtele.pubinfo.boot:pubinfo-boot
xml
<parent>
<groupId>cn.zjtele.pubinfo.boot</groupId>
<artifactId>pubinfo-boot</artifactId>
<version>1.0.0</version>
<relativePath/>
</parent>
该pom中,会统一管理pubinfo-boot相关组件及spring-boot相关组件的版本,使用组件是可以直接引用,不用指定版本。
2、组件使用
在对应开发module的pom中,引入组件坐标即可。如web组件:
xml
<dependency>
<groupId>cn.zjtele.pubinfo.boot</groupId>
<artifactId>pubinfo-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cn.zjtele.pubinfo.boot</groupId>
<artifactId>pubinfo-boot-starter-repository</artifactId>
</dependency>
<dependency>
<groupId>cn.zjtele.pubinfo.boot</groupId>
<artifactId>pubinfo-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>cn.zjtele.pubinfo.boot</groupId>
<artifactId>pubinfo-boot-starter-redis</artifactId>
</dependency>