当前位置:网站首页>Introduction to nexus and detailed tutorial of Xiaobai using idea to package and upload to nexus3 private server
Introduction to nexus and detailed tutorial of Xiaobai using idea to package and upload to nexus3 private server
2022-07-02 17:20:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Use IDEA Package and upload to Nexus3 Private clothes
One 、Nexus What is it?
Start using Maven when , Always hear nexus The word , For a while maven, For a while nexus, Why is it always with maven Mentioned together ?
Maven As a Excellent build tools 、 Dependency management tool 、 Project information management tools , During dependency management , adopt pom.xml Inside
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>To accurately locate and find the corresponding Java Class library . In this process, we need to start from Warehouse To find the corresponding jar The package was introduced into our project , Thus, we solved the problem of Increased dependence 、 Version inconsistency 、 Version conflict 、 Rely on bloated Other questions .
Maven Yes Local repository and Remote warehouse Two kinds of , When Maven When looking for components according to coordinates , It first looks at the local warehouse , If this component exists in the local warehouse , Direct use ; If this component does not exist in the local warehouse , Or you need to see if there is an updated component version ,Maven Will go to the remote warehouse to find , After finding the required artifacts , Download it to the local warehouse and use it again .
When it comes to this , I believe you also understand ,Nexus It's a remote warehouse , It is also a kind of private service .
SNAPSHOT Snapshot version , stay maven in SNAPSHOT Version represents official release (release) Previous development version , stay pom of use x.y-SNAPSHOT Express .
RELEASE The release , Stable version , stay maven in RELEASE Represents a stable version ,unchange, Unalterable , stay maven in SNAPSHOT And RELEASE Version is a completely different way of strategy ,SNAPSHOT It will vary according to your configuration , Frequent updates from remote warehouse to local warehouse ; and RELEASE It will only be downloaded to the local warehouse for the first time , In the future, we will look directly from the local warehouse .
Two 、 Use Nexus3 build maven Private clothes
Find some references on the Internet : Windows Use in Nexus3 build maven Private clothes maven Private clothes nexus3.x build And use Maven Private clothes Nexus3.x Environment build operation record
3、 ... and 、IDEA Package and upload to Nexus3 Private clothes
1. To configure .m2 Under the settings.xml
First , This file is on the system disk of the current device login user .m2 Under the document , Join the authentication mechanism
No, go online copy A configured one , Self configuration is easy to make mistakes
->settings.xml<-
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>maven-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>maven-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>rdc-releases</id>
<username>xxxxxxxxx</username>
<password>xxxxx</password>
</server>
<server>
<id>rdc-snapshots</id>
<username>xxxxxxxxx</username>
<password>xxxx</password>
</server>
</servers>1. To configure IDEA project Under the pom.xml
<distributionManagement>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://xxxx:port/repository/maven-snapshots/</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<name>maven-snapshots</name>
<url>http://xxxx:port/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>Here's the... In the tag id Corresponding to Article 1 server Medium id ,url The obtained value can be written directly here , It can also be shown in the figure below settings Value in file ,name You can customize ->settings.xml<-
<profile>
<altReleaseDeploymentRepository> http://xxxx:port/repository/maven-snapshots/ </altReleaseDeploymentRepository>
<altSnapshotDeploymentRepository> http://xxxx:port/repository/maven-snapshots/</altSnapshotDeploymentRepository>
</profile>Again , above pom.xml Change to the following format
<distributionManagement>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>${altReleaseDeploymentRepository}</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<name>maven-snapshots</name>
<url>${altSnapshotDeploymentRepository}</url>
</snapshotRepository>
</distributionManagement>3. Configure the upload address , Address to private server copy
<profile>
<!--profile Of id-->
<id>dev</id>
<repositories>
<repository>
<!-- Warehouse id,repositories Multiple warehouses can be configured , Guarantee id No repetition -->
<id>nexus</id>
<!-- Warehouse address , namely nexus Address of the warehouse group -->
<url>http://localhost:8081/nexus/content/groups/public/</url>
<!-- Download or not releases artifacts -->
<releases>
<enabled>true</enabled>
</releases>
<!-- Download or not snapshots artifacts -->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- Plug-in repository ,maven It depends on plug-ins , Also need to download plug-ins from private server -->
<pluginRepository>
<!-- Plug in repository id No repetition , If you repeat the back configuration, the front edge will be overwritten -->
<id>central</id>
<name>Nexus Plugin Repository</name>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>4. Other configuration ( Negligible )
For example, configure Ali's image , Map Ali central warehouse ( download jar Hurry up )
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>Configure local warehouse ( No need for networking jar package )
<localRepository>E:\maven_repository</localRepository>5.settings.xml Full configuration ( Source network , For reference only )
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- Local warehouse address -->
<localRepository>D:\mvn_repo\repository</localRepository>
<!-- The following configuration is upload jar Package configuration -->
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<!-- id, In the corresponding project pom.xml Inside distributionManagement Configured id -->
<id>maven-releases</id>
<!-- Sign in nexus Username -->
<username>admin</username>
<!-- Sign in nexus Password -->
<password>admin123</password>
</server>
<server>
<!-- id, In the corresponding project pom.xml Inside distributionManagement Configured id -->
<id>maven-snapshots</id>
<!-- Sign in nexus Username -->
<username>admin</username>
<!-- Sign in nexus Password -->
<password>admin123</password>
</server>
<!-- Configure interceptors mirror Login user name and password . He will intercept all requests to mirror Download from the specified address jar package If you only need to go to the private server to download jar Package, you only need to configure this item -->
<server>
<!-- id, Corresponding mirror in id -->
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<!-- The following configuration is for download jar Package configuration Universal -->
<mirrors>
<!-- To coerce jar Package download private server -->
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.65.129:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<!-- Corresponding activeProfiles-activeProfile The content of -->
<id>nexus</id>
<!-- Warehouse address -->
<repositories>
<repository>
<!-- Private clothes id, Cover maven-model The parent under the module id, Give Way maven Don't go to the central warehouse to download , Go to private server to download -->
<id>central</id>
<!-- name -->
<name>Nexus</name>
<!-- Private address , Write central after , Will go to mirror Inside looking for -->
<url>http://central</url>
<!-- Support releases edition -->
<releases>
<enabled>true</enabled>
</releases>
<!-- Support snapshots edition -->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<!-- Plug-in address -->
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Nexus Plugin Repository</name>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<!-- Configure Global url Address For uploading jar Dynamic acquisition when package -->
<properties>
<ReleaseRepository>http://192.168.65.129:8081/repository/maven-releases/</ReleaseRepository>
<SnapshotRepository>http://192.168.65.129:8081/repository/maven-snapshots/</SnapshotRepository>
</properties>
</profile>
</profiles>
<!-- Choose to use profile -->
<activeProfiles>
<activeProfile>nexus</activeProfile>
<!-- <activeProfile>rdc</activeProfile>-->
</activeProfiles>
</settings>6.IDEA Package and upload
Use idea pack , Packaging will be based on pom In file version Determine whether it is a snapshot version or a release version ,version in 0.0.1-SNAPSHOT belt SNAPSHOT Is the snapshot version , Delete SNAPSHOT Release version for , Upload to private server according to version Automatically determine which warehouse to upload to
Be careful , When the packaging Project pom Make sure that the document is filled with maven-plugin Delete the , Otherwise, after the package is completed, it will generate BOOT-INF Folder , It will cause after uploading to the private server , After the dependency is configured, it can be downloaded to jar package , But no error can be found using the times package
<version>1.1-SNAPSHOT</version>
<build>
</build>then clean after deploy
notice BUILD SUCCESS The prompt is success , You can check on your private server
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/148092.html Link to the original text :https://javaforall.cn
边栏推荐
- Understand one article: four types of data index system
- Goodbye, shucang. Alibaba's data Lake construction strategy is really awesome!
- 远程办公对我们的各方面影响心得 | 社区征文
- In MySQL and Oracle, the boundary and range of between and precautions when querying the date
- 【Leetcode】14. 最长公共前缀
- Usage of sprintf() function in C language
- Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei
- A case study of college entrance examination prediction based on multivariate time series
- GeoServer:发布PostGIS数据源
- QStyle实现自绘界面项目实战(二)
猜你喜欢

宝宝巴士创业板IPO被终止:曾拟募资18亿 唐光宇控制47%股权

智能垃圾桶(五)——点亮OLED

Interpretation of key parameters in MOSFET device manual

LeetCode:1380. Lucky number in matrix -- simple

剑指 Offer 27. 二叉树的镜像

Believe in yourself and finish the JVM interview this time

【Leetcode】14. Longest Common Prefix

如何与博格华纳BorgWarner通过EDI传输业务数据?

上传代码到远程仓库报错error: remote origin already exists.

剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
随机推荐
Use the API port of the bridge of knowledge and action to provide resources for partners to access
The macrogenome microbiome knowledge you want is all here (2022.7)
Fuyuan medicine is listed on the Shanghai Stock Exchange: the market value is 10.5 billion, and Hu Baifan is worth more than 4billion
[shutter] dart data type (dynamic data type)
关于我
Qwebengineview crash and alternatives
【Leetcode】13. 罗马数字转整数
Interpretation of key parameters in MOSFET device manual
Schoolbag novel multithreaded crawler [easy to understand]
One year is worth ten years
Tech talk activity preview | building intelligent visual products based on Amazon kVs
2022 interview questions
What is generics- Introduction to generics
Listing of chaozhuo Aviation Technology Co., Ltd.: raising 900million yuan, with a market value of more than 6billion yuan, becoming the first science and technology innovation board enterprise in Xia
一文看懂:数据指标体系的4大类型
The beginning of life
几行代码搞定RPC服务注册和发现
【Leetcode】13. Roman numeral to integer
Atcoder beginer contest 169 (B, C, D unique decomposition, e mathematical analysis f (DP))
LeetCode:1380. Lucky number in matrix -- simple