mvn构建始终在检查Nexus仓库,无论我在pom文件中放入什么内容。

huangapple go评论84阅读模式
英文:

mvn build keeps checking nexus repos not matter what I put in pom file

问题

我正在尝试通过在pom中包含依赖项来访问一些jar文件。问题是我在公司的nexus仓库中找不到这些依赖项。如何告诉Maven不仅在 http://sl-quality.mycompany.com/nexus/content/groups/public/ 查找依赖项?这个URL在哪里定义的?

    无法解决项目 com.mycompany.myproj:mycompany-service:jar:1.0-SNAPSHOT 的依赖关系:
    找不到 artifact io.confluent.ksql:ksqldb-api-client:jar:0.11.0 在 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 属性 -->
    <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文件放入我的本地仓库。谢谢
英文:

I am trying to access some jar files by including dependencies in the pom. The problem is I get error not found in my corporate nexus repo. How do I tell Maven not to look only in http://sl-quality.mycompany.com/nexus/content/groups/public/ for the dependencies? And where earth is the url defined?

 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>

I have no idea why it always goes to nexus as this is no where mentioned in my pom file. I could install in my local repo but not sure what app jar files need to be pulled for it to work as two repos needed to be added.

I would like to know exactly what jar files i can extract to put in my local repo. Thanks

答案1

得分: 2

仓库通常在位于 C:/Users/Youruser/.m2/settings.xml 路径下的设置文件中进行配置(在 Windows 系统中)。

检查镜像和相应的仓库标签,例如,您的 settings.xml 文件可能如下所示:

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

将此 URL 更改为指向另一个仓库,例如外部的非企业仓库,比如 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>

<!-- 在上面的过滤器中添加其他仓库的设置 -->
<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>
  </repositories>
</profile>
<activeProfiles>
  <activeProfile>nexus</activeProfile>
</activeProfiles>

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

英文:

Repository is generally configured in your settings file located in C:/Users/Youruser/.m2/settings.xml on windows

Check the mirror and corresponding repository tags for example - your settings.xml will probably look like this

 &lt;mirror&gt;
   &lt;id&gt;nexus&lt;/id&gt;
   &lt;mirrorOf&gt;*&lt;/mirrorOf&gt;
   &lt;url&gt;http://sl-quality.mycompany.com/nexus/content/groups/public/&lt;/url&gt;
 &lt;/mirror&gt;

Change this url to point to another repo, perhaps an external non corporate one such as http://repo.maven.apache.org/maven2

EDIT:
I think this is what you want

&lt;mirrors&gt;
  &lt;mirror&gt;
    &lt;id&gt;nexus&lt;/id&gt;
    &lt;mirrorOf&gt;*,!ksqlDB&lt;/mirrorOf&gt;
    &lt;url&gt;http://sl-quality.mycompany.com/nexus/content/groups/public/&lt;/url&gt;
  &lt;/mirror&gt;
&lt;/mirrors&gt;

 &lt;!-- Add repository for your other repo to filter on above --&gt;
 &lt;profile&gt;
  &lt;id&gt;nexus&lt;/id&gt;
 &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;ksqlDB&lt;/id&gt;
      &lt;url&gt;https://ksqldb-maven.s3.amazonaws.com/maven/&lt;/url&gt;
      &lt;releases&gt;
        &lt;enabled&gt;true&lt;/enabled&gt;
      &lt;/releases&gt;
      &lt;snapshots&gt;
        &lt;enabled&gt;true&lt;/enabled&gt;
      &lt;/snapshots&gt;
    &lt;/repository&gt;
&lt;/profile&gt;

</profiles>

&lt;!-- add at bottom inside &lt;/settings&gt; --&gt;
&lt;activeProfiles&gt;
 &lt;activeProfile&gt;nexus&lt;/activeProfile&gt;
&lt;/activeProfiles&gt;

Add more repos as needed and filter above where necessary. I believe (not tested) that you can apply the same exclusions to mirrors instead of repositories personally I prefer using repository tags and having profiles setup.

huangapple
  • 本文由 发表于 2020年9月2日 16:55:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63702080.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定