“camel-restlet-starter”依赖性破解Spring Boot应用程序构建(AuthorizationException)

时间:2018-06-01 17:19:23

标签: java maven spring-boot apache-camel restlet

我遇到的问题与此处描述的类似,但没有相同(成功)的解决方案:

How can I get Restlet via Maven when I am behind a proxy?

基本上,在IntelliJ中,我使用原型创建了一个新的Maven项目:

camel-archetype-spring-boot

我可以成功运行小样本程序(MySpringBootApplication)。

但是一旦我将一个Camel Restlet依赖项添加到POM中:

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-restlet-starter</artifactId>
</dependency>

编译立即失败,并显示:

[...]
    Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.restlet.jee:org.restlet:pom:2.3.12 from/to maven-restlet (http://maven.restlet.org): Access denied to: http://maven.restlet.org/org/restlet/jee/org.restlet/2.3.12/org.restlet-2.3.12.pom , ReasonPhrase:InvalidBrowser.
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:281)
        ... 30 more
    Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact org.restlet.jee:org.restlet:pom:2.3.12 from/to maven-restlet (http://maven.restlet.org): Access denied to: http://maven.restlet.org/org/restlet/jee/org.restlet/2.3.12/org.restlet-2.3.12.pom , ReasonPhrase:InvalidBrowser.
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:951)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:939)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:669)
        at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: org.apache.maven.wagon.authorization.AuthorizationException: Access denied to: http://maven.restlet.org/org/restlet/jee/org.restlet/2.3.12/org.restlet-2.3.12.pom , ReasonPhrase:InvalidBrowser.
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:928)
        at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
        at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
        at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:601)
        ... 4 more

我尝试使用我在Stack Overflow上发现的一些建议,一个涉及在我的pom.xml中添加<repositories>,另一个涉及在settings.xml中添加<mirror>。都没有解决Access Denied问题。

我没有尝试我发现的<server>(在settings.xml中)建议,主要是因为我不知道该条目应该是什么。但我怀疑我真的不需要为这一依赖添加特殊凭据......对吗?

感谢您的帮助!

FWIW,这是我的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/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>camel</groupId>
  <artifactId>restlet</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>

  <name>A Camel Spring Boot Route</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <spring.boot-version>1.5.12.RELEASE</spring.boot-version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- Spring Boot BOM -->
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring.boot-version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <!-- Camel BOM -->
      <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-boot-dependencies</artifactId>
        <version>2.21.1</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <!-- Spring Boot -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-undertow</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <!-- Camel -->
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring-boot-starter</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-stream-starter</artifactId>
    </dependency>

    <!-- XXX: I added this -->
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-restlet-starter</artifactId>
    </dependency>

    <!-- Test -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-test-spring</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${spring.boot-version}</version>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

更新

出于好奇,在用我的浏览器验证后我实际可以访问org.restlet-2.3.12.pom(我无法使用Maven访问它),我想知道如果删除camel-restlet-starter会发生什么依赖,而是尝试指定对编译错误中报告的“违规”依赖关系的依赖:

<dependency>
  <groupId>org.restlet.jee</groupId>
  <artifactId>org.restlet</artifactId>
</dependency>

当我这样做时,我现在得到编译错误:

Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact org.restlet.jee:org.restlet:jar:2.3.12 in central (https://repo.maven.apache.org/maven2)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:947)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:939)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:669)
        at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

事实上,该回复中的工件

进一步深入 最终导致我发现以下开放式错误报告 - 这让我觉得这可能真的是一个错误?

Camel包含对Maven Central中不存在的工件的引用

https://issues.jboss.org/browse/ENTESB-7378

将camel-restlet依赖项添加到pom.xml会导致缺少库

https://issues.jboss.org/browse/OSFUSE-672

0 个答案:

没有答案