springboot连接Nexus私服

简介: springboot连接Nexus私服


image.png

在平时开发过程中可能存在下载jar包过慢或者某些自定义start并不存在于公网仓库中。那么使用私服就是非常必要的。本专栏将介绍springboot如何连接私服。

一.修改maven/conf连接私服

1.maven/conf配置阿里镜像

<?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>
  </pluginGroups>
  <proxies>
  </proxies>
  <servers>    
  </servers>
  <mirrors>
   <mirror>
          <id>alimaven</id>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>        
     </mirror>
  </mirrors>
  <profiles>
  </profiles>
</settings>

2.私服conf配置

<?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>
  </pluginGroups>
  <proxies>
  </proxies>
  <servers>
    <server>
      <id>dev</id>
    <!--用户名密码-->
      <username>账号</username>
      <password>密码</password>
    </server>
  </servers>
  <mirrors>
  <mirror>
      <id>dev</id>
      <mirrorOf>*</mirrorOf>
      <url>http://Nexus-ip:端口/repository/maven-public/</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>  
     <!--profile的id-->
      <id>dev</id>  
    <repositories>  
      <repository> 
      <!--仓库id,repositories可以配置多个仓库,保证id不重复-->
      <id>nexus</id>  
      <!--仓库地址,即nexus仓库组的地址-->
      <url>http://Nexus-ip:端口/repository/maven-public/</url>  
      <!--是否下载releases构件-->
      <releases>  
        <enabled>true</enabled>  
      </releases>  
      <!--是否下载snapshots构件-->
      <snapshots>  
        <enabled>true</enabled>  
      </snapshots>  
      </repository>  
    </repositories> 
     <pluginRepositories> 
      <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
      <pluginRepository> 
        <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
        <id>public</id> 
        <name>Public Repositories</name> 
        <url>http://Nexus-ip:端口/repository/maven-public/</url> 
      </pluginRepository> 
    </pluginRepositories> 
    </profile> 
  </profiles>
   <!-- 开启私服配置-->
   <activeProfiles>
    <activeProfile>dev</activeProfile>
   </activeProfiles>
</settings>

二.通过配置pom文件连接

加入私服地址即可 。

<repositories>
        <repository>
            <id>nexus</id>
            <name>nexus</name>
            <url>http://192.168.xx.xx:8081/repository/maven-public/</url>
        </repository>
    </repositories>

image.png

注意需要将私服设置为任何人都可以下载。

image.png


相关文章
|
1月前
|
关系型数据库 Java 数据库
docker部署postgresql数据库和整合springboot连接数据源
docker部署postgresql数据库和整合springboot连接数据源
45 0
|
1月前
|
Oracle Java 关系型数据库
SpringBoot整合Mybatis连接Oracle数据库
SpringBoot整合Mybatis连接Oracle数据库
SpringBoot整合Mybatis连接Oracle数据库
|
1月前
|
Java 测试技术 数据库
【SpringBoot】连接数据源并回显(附加单元测试)
【SpringBoot】连接数据源并回显(附加单元测试)
17 0
|
7月前
|
消息中间件 Java
springboot RabbitMQ 连接超时配置
springboot RabbitMQ 连接超时配置
293 0
|
1月前
|
Java 关系型数据库 MySQL
基于SpringBoot后端实现连接MySQL数据库并存贮数据
基于SpringBoot后端实现连接MySQL数据库并存贮数据
|
1月前
|
NoSQL Java Redis
SpringBoot连接Redis出现io.lettuce.core.RedisCommandTimeoutException:Commandtimedout解决办法
SpringBoot连接Redis出现io.lettuce.core.RedisCommandTimeoutException:Commandtimedout解决办法
65 0
|
1月前
|
Java 关系型数据库 MySQL
docker 部署springboot项目,连接mysql容器
docker 部署springboot项目,连接mysql容器
163 0
|
10月前
|
Java 数据库
SpringBoot项目连接数据库
SpringBoot项目连接数据库
113 0
|
1月前
|
NoSQL Java Redis
SpringBoot连接redis
SpringBoot连接redis
29 0
|
6月前
|
SQL Java
Springboot 实现 INNER JOIN数据表内连接
本文主要讲解如何使用springboot实现内连接两张表的操作.
41 0