【问题标题】:mvn build keeps checking nexus repos not matter what I put in pom file无论我在 pom 文件中放入什么,mvn build 都会不断检查 nexus repos
【发布时间】:2020-09-02 08:55:48
【问题描述】:

我正在尝试通过在 pom.xml 中包含依赖项来访问一些 jar 文件。问题是我在公司关系存储库中找不到错误。如何告诉 Maven 不要只在 http://sl-quality.mycompany.com/nexus/content/groups/public/ 中查找依赖项? earth 是在哪里定义的 url?

 Could not resolve dependencies for project com.mycompany.myproj:mycompany-service:jar:1.0- 
 SNAPSHOT: Could not find artifact io.confluent.ksql:ksqldb-api-client:jar:0.11.0 in nexus 
 (http://sl-quality.mycompany.com/nexus/content/groups/public/



<?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.mycompany.myapp</groupId>
    <artifactId>com-mycompany-app</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
    <ksqldb.version>0.11.0</ksqldb.version>
    <!-- Maven properties for compilation -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <repositories>
        <!-- jhipster-needle-maven-repository -->
        <repository>
            <id>ksqlDB</id>
            <name>ksqlDB</name>
            <url>https://ksqldb-maven.s3.amazonaws.com/maven/</url>
        </repository>
        <repository>
            <id>confluent</id>
            <name>Confluent</name>
            <url>https://jenkins-confluent-packages-beta-maven.s3.amazonaws.com/6.1.0-beta200715032424/1/maven/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>io.confluent.ksql</groupId>
            <artifactId>ksqldb-api-client</artifactId>
            <version>${ksqldb.version}</version>
        </dependency>
   </dependencies>

我不知道为什么它总是转到 nexus,因为这在我的 pom 文件中没有提到。我可以安装在我的本地存储库中,但不确定需要提取哪些应用程序 jar 文件才能使其工作,因为需要添加两个存储库。

我想确切地知道我可以提取哪些 jar 文件以放入我的本地存储库中。谢谢

【问题讨论】:

  • 你的 settings.xml 中有什么? (C:/Users//.m2/settings.xml) 对于 windows
  • 所以你的权利它丢失了但是当我添加另外两个存储库时它仍然只检查同一个。如果我删除它,那么我会从其他罐子中得到错误..
  • 所以我真的需要保留第一个镜像,因为它包含我所有的公司回购资料。如何使用额外的 repos 来获取我需要的一两个额外的 jar 文件?
  • 我编辑到广告 settings.xml 但因为我的观点很少,还没有人批准它。但基本上你的权利,但我不能只是换掉镜子,因为我需要那个。我需要一种方法来以某种方式使用这两个 repos 来下载 jar!

标签: java spring-boot maven pom.xml ksqldb


【解决方案1】:

存储库通常在 Windows 上位于 C:/Users/Youruser/.m2/settings.xml 的设置文件中配置

例如检查镜像和相应的存储库标签 - 您的 settings.xml 可能看起来像这样

 <mirror>
   <id>nexus</id>
   <mirrorOf>*</mirrorOf>
   <url>http://sl-quality.mycompany.com/nexus/content/groups/public/</url>
 </mirror>

更改此 url 以指向另一个 repo,可能是外部非公司的,例如 http://repo.maven.apache.org/maven2

编辑: 我想这就是你想要的

<mirrors>
  <mirror>
    <id>nexus</id>
    <mirrorOf>*,!ksqlDB</mirrorOf>
    <url>http://sl-quality.mycompany.com/nexus/content/groups/public/</url>
  </mirror>
</mirrors>

 <!-- Add repository for your other repo to filter on above -->
 <profile>
  <id>nexus</id>
 <repositories>
    <repository>
      <id>ksqlDB</id>
      <url>https://ksqldb-maven.s3.amazonaws.com/maven/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
</profile>
<!-- add at bottom inside </settings> -->
<activeProfiles>
 <activeProfile>nexus</activeProfile>
</activeProfiles>

根据需要添加更多存储库,并在必要时进行过滤。我相信(未经测试)您可以将相同的排除应用于镜像而不是存储库,我个人更喜欢使用存储库标签并设置配置文件。

【讨论】:

  • nexusnexustrue
  • 我注意到只有一个配置文件处于活动状态,它是 nexus?也许这就是为什么?
  • 我添加了镜像,但只查看了关系
  • 我不知道在这里放什么? nexus
  • 逗号列表或如何为镜像仓库创建配置文件?活动配置文件是逗号分隔的列表吗?
猜你喜欢
  • 1970-01-01
  • 2016-07-14
  • 2011-04-26
  • 2012-10-22
  • 2016-10-30
  • 2019-09-06
  • 2017-10-27
  • 1970-01-01
  • 2020-06-03
相关资源
最近更新 更多