无法将 camel-http4 添加到 Eclipse 中的 Maven Camel 项目

Trouble adding camel-http4 to Maven Camel project in Eclipse

我正在尝试将 http4 添加到我的 Camel 项目中。根据文档,看起来我只需要使用 Camel 版本添加这两个 Maven 依赖项。但是我从 Eclipse 中得到一个错误:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-http4</artifactId>
    <version>${camel-version}</version>
</dependency>
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-http4-starter</artifactId>
  <version>${camel-version}</version>
</dependency>

但 Eclipse 报错:“缺少工件 org.apache.camel:camel-http4:jar:3.11.1”

我没有在列表中看到相关性。我尝试使用 Maven > 更新项目。我还尝试关闭并重新打开该项目。我也尝试将这些添加到另一个项目并得到同样的东西。我不确定这里有什么问题。

这是我的pom

<?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>systems.petsuppliesplus</groupId>
  <artifactId>email-processor</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>2.5.3</spring.boot-version>
    <surefire.plugin.version>3.0.0-M4</surefire.plugin.version>
    <camel-version>3.11.1</camel-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.springboot</groupId>
        <artifactId>camel-spring-boot-dependencies</artifactId>
        <version>${camel-version}</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.springboot</groupId>
      <artifactId>camel-spring-boot-starter</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel.springboot</groupId>
      <artifactId>camel-stream-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-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    
    <!-- Additions -->
    
    <!-- For receiving JMS messages from Artemis -->
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>artemis-jms-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.camel.springboot</groupId>
        <artifactId>camel-jms-starter</artifactId>
    </dependency>
    <dependency>
       <groupId>org.messaginghub</groupId>
       <artifactId>pooled-jms</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.json</groupId>
        <artifactId>javax.json-api</artifactId>
    </dependency>
    
    <!--  Calling HTTP (REST) -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-http4</artifactId>
        <version>${camel-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-http4-starter</artifactId>
      <version>${camel-version}</version>
    </dependency>
    
    <!-- Model Object Traslation -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jackson</artifactId>
        <version>${camel-version}</version>
    </dependency>
    
  </dependencies>
  

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <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>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire.plugin.version}</version>
      </plugin>
    </plugins>
  </build>

</project>

我尝试重新索引本地存储库,并尝试使用其他一些 Eclipse 技巧来尝试刷新内容,但它们似乎没有帮助。我也试过使用 camel-http。这找到了罐子,但没有找到启动器。

    <!--  This one works -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-http</artifactId>
        <version>${camel-version}</version>
    </dependency>
   <!-- But this one still give the missing artifact error -->
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-http-starter</artifactId>
      <version>${camel-version}</version>
    </dependency>

camel-http4 已在 Camel 3.x 中重命名,您可以在 migration guide.

中找到它

原因是比 4.x 更老的 http-clients 被 Camel 3.x 删除了,所以 camel-http4 现在是唯一的,因此只是 camel-http。

Camel 2.x 中引用的内容为

<groupId>org.apache.camel</groupId>
<artifactId>camel-http4-starter</artifactId>

已在 Camel 3.x 中更改为

<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-http-starter</artifactId>

注意 groupId 中的“springboot”和 artifactId 中的“http”。