Use nexus to build a LAN private server
Using nexus to build a LAN private server
1. Understanding the maven warehouse
1.1 The role of the maven warehouse
I think back to the time when maven was not used before, we used the original project skeleton of eclipse When building a project, there is often a lib folder in the project directory to store the jar files required for the project. Every time a new project is built, there will be such a lib folder. Then copy the jar into the lib folder configuration path. Obviously there is a lot of repeated work, and the jar packages used in different projects are different, so we need to slowly distinguish them. Then we used project management tools such as svn or git, and we needed to introduce a large number of jar files into the code base, which was not very appropriate.
Maven can help us solve these problems. The maven warehouse is a location specifically used to store jar files (it can also be used to store project war, zip, pom and other files). Each jar file is assigned a coordinate in the maven warehouse, such as the jstl jar package:
<groupid>javax.servlet</groupid> 组ID <artifactid>jstl</artifactid> 构建ID ... 其余属性后续介绍
In this way, maven can easily control the project dependency version. Simply put, the maven warehouse helps us manage project components in a unified manner.
1.2 Maven warehouse classification
## The query path of project construction: first query the local warehouse, if not found, the central warehouse will be queried, if not found, an error will be reported. The central warehouse address is:
- Private server nexus uses
- . It is recommended to use the
-
above. Three are more common and are used more often in projects. However, due to the slow download speed and incomplete jar files in the warehouse, actual enterprise development requires us to build a private server warehouse.
2. Install and use nexus Note here that building a maven private server is not just a tool. The version used by the blogger is nexus-2.12.0. Click to download, password: 1ar1
- Unzip after downloading is complete Yes, after decompression is completed, you can see it in the directory nexus-2.12.0-01-bundle\nexus-2.12.0-01\bin\jsw:
-
3. Configure maven private server
- #Click Login in the upper right corner to log in
. The initial account is admin and the password is admin123. It can be modified after successful login. You can find your account password yourself.
- Click on the navigation Respositories
on the left.
You can see that there are some warehouses by default. The meaning of warehouse type Type:
- hosted host warehouse, used Publish some components that are not allowed by third parties, such as jar packages of commercial software such as Oracle drivers
- proxy proxy remote warehouses, such as the three maven remote warehouses written above. If certain jar files do not exist locally, they will be downloaded from these proxy sites.
- releases The release warehouse of the release module in the internal module
- snapshots The warehouse where the internal snapshot module is released
- 3rd party is a third-party dependent warehouse. After uploading the jar package locally, use the
- group warehouse to add other warehouses to facilitate developers to set up
- Start building the private server warehouse. It is worth noting: maven project index: the maven project index is used to facilitate the search for related dependency builds on the private server site. Therefore, before building a private server, you should download the maven index, which is about tens of MB:
Change the Download Remote Indexes property to True, and then click save. You can view it in the menu bar Scheduled Tasks The progress of downloading the index.
Add your own proxy remote library
, sometimes our project needs to introduce some special jar files, such as some jar packages of Jboss. At this time, we can also proxy the remote warehouse in the private server. :Click add to add the proxy type, fill in the id, name and url in order. In this case,
Remote warehouse: 4.Use nexus to build a LAN private server的使用,上面提到的一些特殊的商业性质相关的jar文件,比如oracle的驱动包,ojdbc.jar并不支持远程下载,这时候可以将我们本地下载好的jar包上传到私服。 注意GAV设置要与你pom.xml中一致,上传后添加到Artifacts点击上传即可: 切记点击刷新,刷新后点击唯一的一个group仓库,点击配置Configuration就可以看到刚才我们手动添加的代理仓库,然后将代理仓库添加到组仓库,这样依赖,项目中之需要配置组仓库的url就可以访问多个私服仓库。 在上述步骤完成后,即可在项目中引用私服,pom.xml中改变默认下载仓库url: 指定插件仓库 配置好之后就可以从私服下载依赖包了。但是这种方式只能在改项目中起作用,每次配置项目都需要写两遍,为了将懒人模式进行到底,我们还可以指定全局的私有仓库。 找到maven文件的中的Use nexus to build a LAN private server文件 在Use nexus to build a LAN private server中添加配置:<repository>
<id>jboss</id>
<name>JBoss Repository</name>
<url>;/url>
<releases>
<updatepolicy>daily</updatepolicy><!-- never,always,interval n -->
<enabled>true</enabled>
<checksumpolicy>warn</checksumpolicy><!-- fail,ignore -->
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<layout>default</layout>
</url></repository>
5.由于私服仓库数量过多,导致配置复杂度提高,所以需要用到上述的group类型仓库:四. 局域网使用maven私服
4.1 单个项目使用maven私服
指定私服仓库,我的ip是170,不要全盘复制<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.168.1.170:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginrepositories>
<pluginrepository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.168.1.170:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginrepository>
</pluginrepositories>
4.2 全局指定私服
在profiles
<profile> <repositories> <id>central</id> <name>central</name> <url>http://192.168.1.170:8081/nexus/content/groups/public/</url> <layout>default</layout> <releases> <enabled>true<enabled> </enabled></enabled></releases> <snapshots> <enabled>true<enabled> </enabled></enabled></snapshots> </repositories> </profile>
配置好之后激活profile
<activeprofiles> <activeprofile>central</activeprofile> </activeprofiles>
这样一来,这台电脑上所有maven项目下载jar文件时都会先访问局域网170的电脑。
-----------------------------------windows配置私服完毕-----------------------------------
扩展:setting,xml中各标签的意义:
servers(服务器)
<servers> <server> <id>server001</id> <username>my_login</username> <password>my_password</password> <privatekey>${usr.home}/.ssh/id_dsa</privatekey> <passphrase>some_passphrase</passphrase> <filepermissions>664</filepermissions> <directorypermissions>775</directorypermissions> <configuration></configuration> </server> </servers>
id与pom.xml中distributionManagement的id保持一致,服务器标识
username和password表示服务器认证需要的用户民和密码
privateKey, passphrase一组密钥 (不常用)
filePermissions, directoryPermissions如果在部署的时候会创建一个仓库文件或者目录,这时候就可以使用权限(不常用)
2.mirrors(镜像)
<mirrors> <mirror> <id>planetmirror.com</id> <name>PlanetMirror Australia</name> <url>;/url> <mirrorof>central</mirrorof> </url></mirror> </mirrors>
设置一个中央仓库的镜像,看仓库分类,也是远程仓库的一种配置方式。
3.profiles(构建环境)
这个可能比较难理解,maven权威指南一书中这样说:
Profile能让你为一个特殊的环境自定义一个特殊的构建;
构建环境的两个例子是产品环境和开发环境。当你在开发环境中工作时,你的系统可能被配置成访问运行在你本机的开发数据库实例,而在产品环境中,你的系统被配置成从产品数据库读取数据。Maven能让你定义任意数量的构建环境(构建profile),这些定义可以覆盖pom.xml中的任何配置。
简单理解就是你可以先profile中先构件好项目运行的环境,比如预设了A环境实在开发中使用,而实际上线是B环境,那么在上线的时候我们不需要一个个修改pom.xml中的配置,只需要激活改profile即可。
4.activation(激活构建环境 )
<activation> <activebydefault>false</activebydefault> <jdk>1.5</jdk> <os> <name>Windows XP</name> <family>Windows</family> <arch>x86</arch> <version>5.1.2600</version> </os> <property> <name>mavenVersion</name> <value>2.0.3</value> </property> </activation>
指定profile中配置的环境在什么时候开始生效
5.activeProfiles(激活了的profile)
<activeprofiles> <activeprofile>env-test</activeprofile> </activeprofiles>
在Use nexus to build a LAN private server最后的一个标签,表示env-test这个profile已被激活
The above is the detailed content of Use nexus to build a LAN private server. For more information, please follow other related articles on the PHP Chinese website!

JVMmanagesgarbagecollectionacrossplatformseffectivelybyusingagenerationalapproachandadaptingtoOSandhardwaredifferences.ItemploysvariouscollectorslikeSerial,Parallel,CMS,andG1,eachsuitedfordifferentscenarios.Performancecanbetunedwithflagslike-XX:NewRa

Java code can run on different operating systems without modification, because Java's "write once, run everywhere" philosophy is implemented by Java virtual machine (JVM). As the intermediary between the compiled Java bytecode and the operating system, the JVM translates the bytecode into specific machine instructions to ensure that the program can run independently on any platform with JVM installed.

The compilation and execution of Java programs achieve platform independence through bytecode and JVM. 1) Write Java source code and compile it into bytecode. 2) Use JVM to execute bytecode on any platform to ensure the code runs across platforms.

Java performance is closely related to hardware architecture, and understanding this relationship can significantly improve programming capabilities. 1) The JVM converts Java bytecode into machine instructions through JIT compilation, which is affected by the CPU architecture. 2) Memory management and garbage collection are affected by RAM and memory bus speed. 3) Cache and branch prediction optimize Java code execution. 4) Multi-threading and parallel processing improve performance on multi-core systems.

Using native libraries will destroy Java's platform independence, because these libraries need to be compiled separately for each operating system. 1) The native library interacts with Java through JNI, providing functions that cannot be directly implemented by Java. 2) Using native libraries increases project complexity and requires managing library files for different platforms. 3) Although native libraries can improve performance, they should be used with caution and conducted cross-platform testing.

JVM handles operating system API differences through JavaNativeInterface (JNI) and Java standard library: 1. JNI allows Java code to call local code and directly interact with the operating system API. 2. The Java standard library provides a unified API, which is internally mapped to different operating system APIs to ensure that the code runs across platforms.

modularitydoesnotdirectlyaffectJava'splatformindependence.Java'splatformindependenceismaintainedbytheJVM,butmodularityinfluencesapplicationstructureandmanagement,indirectlyimpactingplatformindependence.1)Deploymentanddistributionbecomemoreefficientwi

BytecodeinJavaistheintermediaterepresentationthatenablesplatformindependence.1)Javacodeiscompiledintobytecodestoredin.classfiles.2)TheJVMinterpretsorcompilesthisbytecodeintomachinecodeatruntime,allowingthesamebytecodetorunonanydevicewithaJVM,thusfulf


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
