java - 为什么maven从spring repo下载jar?
问题描述
我在 settings.xml 和 pom.xml 中有一个像这样的镜像
设置.xml
<?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">
<localRepository>${user.home}/.m2/repository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>nexus-release</id>
<username>username</username>
<password>password</password>
</server>
<server>
<id>nexus-snapshot</id>
<username>username</username>
<password>password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus-any</id>
<mirrorOf>central</mirrorOf>
<name>Nexus any</name>
<url>http://anyHost:2227/repository/maven-public</url>
</mirror>
</mirrors>
<profiles>
</profiles>
</settings>
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.projecy</groupId>
<artifactId>my-project</artifactId>
<packaging>pom</packaging>
<version>1.3.0</version>
<modules>
<module>my-project-pool</module>
<module>my-project-business</module>
<module>my-project-web-deploy</module>
<module>my-project-task-deploy</module>
<module>my-project-stats</module>
<module>my-project-bizlog</module>
</modules>
<name>my-project</name>
<description>Educational Administration Offline System</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<mybatis.version>1.3.2</mybatis.version>
<httpClient.version>4.5.5</httpClient.version>
<maven.plugins.jar.version>3.1.0</maven.plugins.jar.version>
<maven.plugins.assembly.version>3.1.0</maven.plugins.assembly.version>
<offline.api.version>1.3.1-SNAPSHOT</offline.api.version>
<online.api.version>1.3.0-SNAPSHOT</online.api.version>
<starter.httpclient.version>1.0.0-SNAPSHOT</starter.httpclient.version>
<lombok.version>1.16.2</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.my.projecy.starter</groupId>
<artifactId>httpclient-starter</artifactId>
<version>${starter.httpclient.version}</version>
</dependency>
<dependency>
<groupId>com.my.projecy</groupId>
<artifactId>bluesky-common</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.my.projecy</groupId>
<artifactId>ea-api-online</artifactId>
<version>${online.api.version}</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpClient.version}</version>
</dependency>
<dependency>
<groupId>com.my.projecy</groupId>
<artifactId>my-project-pool</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.my.projecy</groupId>
<artifactId>my-project-business</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.my.projecy</groupId>
<artifactId>my-project-web-deploy</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.my.projecy</groupId>
<artifactId>my-project-task-deploy</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.my.projecy</groupId>
<artifactId>ea-api-offline</artifactId>
<version>${offline.api.version}</version>
</dependency>
<dependency>
<groupId>com.my.projecy</groupId>
<artifactId>my-project-stats</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.my.projecy</groupId>
<artifactId>my-project-bizlog</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven.plugins.assembly.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
但是当我尝试编译我的项目时,我得到了这个错误:
Could not find artifact com.my.package:httpclient-starter:jar:1.0.0-SNAPSHOT
in spring-snapshot (https://repo.spring.io/snapshot)
- 我试图删除本地 repo 下的所有文件夹或
mvn clean compile -U
- 我用 settings.xml 和 pom.xml 尝试了 grep "repo.spring.io" 但什么也没得到
- 仅使用单个 repo 对我有用。
像这样:
<mirror>
<id>my-id</id>
<mirrorOf>*</mirrorOf>
<name>any name</name>
<url>http://anyHost:2227/repository/maven-public</url>
</mirror>
我怎么知道为什么 maven 从 spring repo 下载这个依赖?
解决方案
让我们从从 Spring 的快照存储库中下载 Maven 的部分开始。从您在问题中向我们展示的内容来看,至少不清楚(如果不存在)您在项目中定义了任何快照存储库。因为这是一个 Spring Boot 项目,它会通过父项目(..repo.spring.io..
)给你设置一个。这就是为什么您的项目会访问此特定服务器的原因。
您尝试下载一个您可能自己放入nexus的jar,对吗?该版本<sth>-SNAPSHOT
使 Maven 尝试从某个快照服务器获取。
您的镜像必须是mirrorOf
中央存储库,我只是假设您的 jar 不在镜像中,而是“在”镜像中。
我的想法是将您的镜像设置为项目中的存储库,pom.xml
如下所示
<repositories>
<repository>
<id>myInternalRepository</id>
<url>http://localhost:8081/nexus/content/groups/???</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
推荐阅读
- c++ - C++ auto on int16_t 强制转换为整数
- java - 在给定数据上循环特征文件
- laravel - laravel 事件和 laravel 函数有什么区别?
- mysql - 如何将多个值连接到一列结果中
- mysql - 需要一种将电子邮件模板存储在 s3 中并将模板的密钥存储在 mysql 中的方法
- vue.js - MathJax 也不使用 Vuejs $router.push
- html - 从不同的网站提取元素
- java - 在 kibana 中匹配错误条件后获取电子邮件/ SNS 通知
- karate - 无法为功能启用 @ignore 注释
- apache-nifi - Apache NiFi 立即关闭并出现错误,org.apache.nifi.StdErr 无法启动 Web 服务器