微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Maven在错误的仓库中寻找atifact

如何解决Maven在错误的仓库中寻找atifact

该项目正在寻找来自Maven Central的otj-pg-embedded依赖项。但是,它失败并显示错误

Plugin org.codehaus.mojo:exec-maven-plugin:1.3.2 or one of its dependencies Could not be resolved: Could not find artifact org.codehaus.mojo:exec-maven-plugin:jar:1.3.2 in central (https://loyalty.jfrog.io/loyalty/plugins-release)

pom.xml文件如下所示

<modelVersion>4.0.0</modelVersion>

<groupId>com.loyalty.finance</groupId>
<artifactId>fin-trx-event-consumer</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>fin-trx-event-consumer</name>
<description>Finance Consumer</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
    <relativePath />
</parent>

<properties>

    <com.amazonaws.kinesis.version>1.11.438</com.amazonaws.kinesis.version>
    <spock.version>1.1-groovy-2.4</spock.version>
    <groovy.version>2.4.12</groovy.version>
    <consumer.client.library>5.1.0</consumer.client.library>
</properties>

<dependencies>
    <dependency>
        <groupId>com.opentable.components</groupId>
        <artifactId>otj-pg-embedded</artifactId>
        <version>0.13.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-kinesis</artifactId>
        <version>${com.amazonaws.kinesis.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-ses</artifactId>
        <version>1.11.416</version>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>42.2.2</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.3</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.2.3</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.25</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.7.25</version>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.10.19</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.196</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.spockframework</groupId>
        <artifactId>spock-spring</artifactId>
        <version>${spock.version}</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>${groovy.version}</version>
    </dependency>
    <dependency>
        <groupId>com.loyalty</groupId>
        <artifactId>consumer-client-library</artifactId>
        <version>${consumer.client.library}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>5.0.7.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.github.ulisesbocchio</groupId>
        <artifactId>jasypt-spring-boot-starter</artifactId>
        <version>1.15</version>
    </dependency>


</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>addTestSources</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>

            <configuration>
                <skip>false</skip>
                <includes>
                    <include>**/*Spec.java</include>
                    <include>**/*Test.java</include>
                </includes>
                <excludes>
                    <exclude>**/BaseSpec.java</exclude>
                </excludes>
                <environmentvariables>
                    <AWS_CBOR_disABLE>1</AWS_CBOR_disABLE>
                </environmentvariables>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>

        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <!-- Todo exclude junit test when we are running integration test -->
                <includes>
                    <include>**/*.java</include>
                </includes>
                <!--<groups>com.loyalty.finance.kinesis.client.junit.UnitTest</groups> -->
            </configuration>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
                <execution>
                    <id>verify</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>1.0.0</version>
            <configuration>
                <useConfigFile>true</useConfigFile>
                <registryUrl>https://277983268692.dkr.ecr.us-east-1.amazonaws.com</registryUrl>
                <imageName>277983268692.dkr.ecr.us-east-1.amazonaws.com/${project.name}</imageName>
                <baseImage>277983268692.dkr.ecr.us-east-1.amazonaws.com/docker-slim-java</baseImage>
                <entryPoint>["/usr/local/bin/get-rds-certs","/usr/local/bin/kms-env-java","/startApp.sh"]</entryPoint>
                <imageTags>
                    <imageTag>${build.number}</imageTag>
                </imageTags>
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${basedir}/src/main/resources/scripts</directory>
                        <include>startApp.sh</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>build-info</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/lib</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

和settings.xml看起来像这样

<settings
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://maven.apache.org/SETTINGS/1.1.0"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

<servers>
  <server>
    <username>travis</username>
    <!--encrypt these passwords in future-->
    <password>AP39AmWxccbqrCzW118Abj2qwY6</password>
    <id>central</id>
  </server>
  <server>
    <username>travis</username>
    <!--encrypt these passwords in future-->
    <password>AP39AmWxccbqrCzW118Abj2qwY6</password>
    <id>snapshots</id>
  </server>
</servers>
<profiles>
  <profile>
    <repositories>
      <repository>
        <snapshots>
          <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>libs-release</name>
        <url>https://loyalty.jfrog.io/loyalty/libs-release</url>
      </repository>
      <repository>
        <snapshots/>
        <id>snapshots</id>
        <name>libs-snapshot</name>
        <url>https://loyalty.jfrog.io/loyalty/libs-snapshot</url>
      </repository>
    </repositories>
    <pluginRepositories>
      <pluginRepository>
        <snapshots>
          <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>plugins-release</name>
        <url>https://loyalty.jfrog.io/loyalty/plugins-release</url>
      </pluginRepository>
      <pluginRepository>
        <snapshots/>
        <id>snapshots</id>
        <name>plugins-release</name>
        <url>https://loyalty.jfrog.io/loyalty/plugins-release</url>
      </pluginRepository>
    </pluginRepositories>
    <id>artifactory</id>
  </profile>
</profiles>
<activeProfiles>
  <activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>

它将在settings.xml中定义的位置查找该工件。我该如何改变。而且我需要settings.xml,因为有一些来自jfrog的依赖项,这些依赖项是在settings.xml中定义的

我什至尝试了强制更新-U,但这不起作用 mvn -U清洁包-s settings.xml

解决方法

您的settings.xml使用central ID覆盖了MavenCentral的位置。

如果您不想这么做,请在settings.xml中使用其他ID。

,

我认为您将Url覆盖到了中央Maven存储库。 尝试在以下位置更改ID:

<pluginRepository>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
    <id>central</id>
    <name>plugins-release</name>
    <url>https://loyalty.jfrog.io/loyalty/plugins-release</url>
  </pluginRepository>

repository

相同

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。