移动神器RAX3000M路由器不刷固件变身家庭云之五(高级应用):设置成maven私服

由于我们项目经常会使用一些自研的公共组件,把这些组件放在一个共同的maven私服,这样大家就可以自动下载这些组件了。

前面文章里,我们设置好了uhttpd和vsftpd两个服务,http服务把管理界面移到隐藏的子目录里了。

现在我们可以把路由变成maven私服,我的方案是,建一个目录(/mnt/usb/sda1/mvn)作为私服存储。开发人员可能通过vsftpd把组件部署到这个目录里,maven可以通过http://xxxx.xxx.xx/mvn 来下载组件。

下面一步步开干:

增加用户mvn,以便上传组件

复制代码
adduser -h /mnt/usb/sda1/mvn -s /bin/false -G ftp mvn

输入再次密码,用户创建好了,可以从ftp登录看看。记得我们在vsftpd设置时,建议大家启用:

chroot_local_user=YES

这样的话,现在mvn登录ftp应该直接被限制在/mnt/usb/sda1/mvn这个目录下面了。

去检查一下这个目录应该已经被自动创建了:

/mnt/usb/sda1/mvn

现在我们要让mvn deploy命令把组件部署到仓库里了

设置maven组件部署

在我们项目的根pom里,添加如下内容:

xml 复制代码
    <distributionManagement>
        <repository>
            <id>xxx-maven-repo-rel</id>
            <name>xxx Release Repo</name>
            <url>ftp://xxx.dynv6.net:8021/</url>
        </repository>
        <snapshotRepository>
            <id>xxx-maven-repo-sn</id>
            <name>xxx Release Repo</name>
            <url>ftp://xxx.dynv6.net:8021/</url>
        </snapshotRepository>
    </distributionManagement>

在用户主目录下的.m2目录下有个settings.xml文件, 加上认证信息

xml 复制代码
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->
    <server>
      <id>xxx-maven-repo-rel</id>
      <username>mvn</username>
      <password>password</password>
    </server>
    <server>
      <id>xxx-maven-repo-sn</id>
      <username>mvn</username>
      <password>password</password>
    </server>
  </servers>

好了,现在执行下mvn deploy命令看看是不是能上传组件了?

设置maven下载你的组件

这步就很简单了,在我们项目的根pom里,添加如下内容:

xml 复制代码
    <repositories>
        <repository>
            <id>iisp</id>
            <name>iisp-repo</name>
            <url>http://xxx.dynv6.net:8080/mvn/</url>
        </repository>

注意:3.6以后的版本不支持http了,只支持https。

后续文章会讲到怎么配置https ...

移动神器RAX3000M路由器变身家庭云之一:开通SSH,安装新软件包
移动神器RAX3000M路由器变身家庭云之二:安装vsftpd
移动神器RAX3000M路由器变身家庭云之三:外网访问家庭云

移动神器RAX3000M路由器不刷固件变身家庭云之五(高级应用):设置成maven私服
移动神器RAX3000M路由器变身家庭云之四:开放LuCI管理界面,网站服务
移动神器RAX3000M路由器不刷固件变身家庭云之六(高级应用):设置https

相关推荐
4***W4296 分钟前
SpringCloud实战十三:Gateway之 Spring Cloud Gateway 动态路由
java·spring cloud·gateway
程序员-周李斌7 分钟前
ArrayList 源码深度分析(基于 JDK 8)
java·开发语言·数据结构·算法·list
safestar20129 分钟前
Spring Boot的魔法与陷阱:从自动配置原理到生产环境避坑实战
java·spring boot·后端
v***553410 分钟前
Spring Boot环境配置
java·spring boot·后端
J***516811 分钟前
Spring Cloud GateWay搭建
java
IT·小灰灰13 分钟前
深度解析重排序AI模型:基于硅基流动API调用多语言重排序AI实战指南
java·大数据·javascript·人工智能·python·数据挖掘·php
一辉ComeOn14 分钟前
【大数据高并发核心场景实战】 数据持久化层 - 分表分库
java·大数据·分布式·mysql·系统架构
极客BIM工作室16 分钟前
ZFNet反卷积网络(Deconvnet):让CNN“黑盒”变透明的核心技术
网络·人工智能·cnn
g***727020 分钟前
Spring Framework 中文官方文档
java·后端·spring
v***56520 分钟前
Spring Boot spring-boot-maven-plugin 参数配置详解
spring boot·后端·maven