志宇-nexus学习
nexus /ˈneksəs/
- 环境安装
- nexus安装
- nexus 使用
- 登录nexus
- 创建一个公司的私有仓库,然后添加到私服的中央仓库中
- 私服代理配置成阿里云镜像
- maven加载setting文件
- jar包上传到私服的方法
- 配置maven的setting配置文件连接私服
- 修改pom文件连接私服
- 将项目打成jar包上传私服
- 上传jar包
环境安装
jdk和maven安装
vim /etc/profile
在最下面,添加一下内容
激活配置
source /etc/profile
检测安装
java -version
解压maven
tar -zxvf apache-maven-3.5.3-bin.tar.gz -C /usr/local/
配置maven环境变量
vim /etc/profile
在最下面,添加一下内容
激活配置
source /etc/profile
检测安装
mvn -v
nexus安装
1.解压
tar -zxvf nexus-3.12.1-01-unix.tar.gz -C /usr/local/
2.开启端口
修改配置文件 修改对应的端口
vim /usr/local/nexus-3.12.1-01/etc/nexus-default.properties
修改防火墙
vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT
重启防火墙
service iptable restart
3.创建新用户(nexus不建议使用root用户启动)
user add nexus
给用户赋予访问解压文件的权限
chown -R nexus:nexus sonatype-work/
chown -R nexus:nexus snexus-3.12.1-01/
4 切换用户
su nexus
5 修改配置文件
vim /bin/nexus.vmoptions 修改内存占用大小
6来到bin目录下启动
./nexus start 进行启动(如果启动不成功不显示报错信息)
./nexus run (不启动,但是启动报错能看到报错信息)
7 查看是否启动成功
开是否开启
ps -ef | grep nexus
等一会看端口开放没有
netstat -ano | grep (nexus的端口)
然后就启动成功了
8.修改最大文件数
查看最大文件数
ulimit -a
修改最大文件数
vim /etc/security/limits.conf 在最后添加下面的配置
root soft nofile 65535
root hard nofile 65535
root代表的用户,如果将将root 改成 * 则代表所有人
然后重启生效
9.配置重启自动开启nexus
vim /etc/rc.d/rc.local
在配置中加入
su - nexus -c '/usr/local/nexus-3.12.1-01/bin/nexus start'
nexus 使用
登录nexus
使用admin/admin123
创建一个公司的私有仓库,然后添加到私服的中央仓库中
私服代理配置成阿里云镜像
将代理地址改成国内地址
http://maven.aliyun.com/nexus/content/groups/public/
maven加载setting文件
在idea中默认会先去 .m2中加载
jar包上传到私服的方法
私服上面上传jar包的三种方法
一、开发所使用的setting配置文件指向私服,开发下载的依赖会自动添加到私服中
二、将整个项目打包上传,使用maven的deploy
三、手动将jar包上传
配置maven的setting配置文件连接私服
修改setting配置文件
<?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"><pluginGroups/><proxies/><servers><server><!-- 私有库名称 --><id>lizhiyu-releases</id><!-- 私有库登录用户名 --><username>admin</username><!-- 私有库登录密码 --><password>admin123</password></server><server> <!-- 私有库名称 (插件库)--><id>lizhiyu-snapshots</id><!-- 私有库登录用户名 --><username>admin</username><!-- 私有库登录密码 --><password>admin123</password></server></servers><mirrors/><profiles><profile><id>lizhiyu</id><activation><activeByDefault>false</activeByDefault></activation><!-- 私有库地址--><repositories><repository><id>lizhiyu</id><url>http://www.lizhiyu.xyz:9000/repository/maven-public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><!--插件库地址--><pluginRepositories><pluginRepository><id>lizhiyu</id><url>http://www.lizhiyu.xyz:9000/repository/maven-public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories></profile></profiles><!--激活配置--><activeProfiles><activeProfile>lizhiyu</activeProfile></activeProfiles> </settings>私有库和插件库的url如下
修改pom文件连接私服
修改项目中的配置文件pom,会覆盖maven中的setting配置文件
<properties><java.version>1.8</java.version><spring-cloud.version>Hoxton.SR8</spring-cloud.version><nacos.version>2.2.3.RELEASE</nacos.version><swagger.version>2.8.0</swagger.version></properties><profiles><!-- 开发环境配置 --><profile><id>dev</id><properties><sino.nexus.url>https://maven.aliyun.com/repository/public</sino.nexus.url></properties><activation><!-- 设置默认激活这个配置 --><activeByDefault>true</activeByDefault></activation></profile><!-- 发布环境配置 --><profile><id>publish</id><properties><sino.nexus.url>http://bjmaven.aviva-cofco.com.cn/repository/internal/</sino.nexus.url></properties></profile></profiles><!--dependency和 dependencyManagement区别在于--><!--dependencyManagement可以允许子项目修改版本--><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><dependencies></dependencies><modules><!-- 活动量服务 --><module>app-activity-server</module><!-- 后台管理和批处理服务服务 --><module>app-manage-server</module></modules><repositories><repository><id>nexus</id><url>http://bjmaven.aviva-cofco.com.cn/repository/internal/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>nexus</id><url>http://bjmaven.aviva-cofco.com.cn/repository/internal/</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories>将项目打成jar包上传私服
先将本地maven连接私服,然后项目中pom文件添加配置信息,然后在项目中deploy发布即可
pom中配置信息如下
<distributionManagement><repository>这个id一定要和maven中配置的信息相同<id>lizhiyu-releases</id><name>Ruizhi Release Repository</name><url>http://www.lizhiyu.xyz:9000/repository/maven-releases/</url></repository> <snapshotRepository>这个id一定要和maven中配置的信息相同<id>lizhiyu-snapshots</id><name>Ruizhi Snapshot Repository</name><url>http://www.lizhiyu.xyz:9000/repository/maven-snapshots/</url></snapshotRepository></distributionManagement>pom.xml 远程仓库的配置 id要跟本地maven的setting.xml中的server中的id相同
pom.xml 远程仓库的配置 url要跟nexus中的url相同
url地址如下
上传jar包
引入jar包
总结
以上是生活随笔为你收集整理的志宇-nexus学习的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 志宇-Nginx学习
- 下一篇: 【RDMA】infiniband网卡安装