Spring boot 使用RestBindingMode.auto获取驼峰错误

Spring boot 使用RestBindingMode.auto获取驼峰错误,spring-boot,rest,maven,apache-camel,Spring Boot,Rest,Maven,Apache Camel,在下一行.bindingMode(RestBindingMode.auto)上运行springboot Camel和maven时,我遇到了一个错误 我是不是缺少了一些依赖? 我认为这应该不是问题,因为我的pom.xml中有下一个依赖项,我不知道为什么会出现这个错误 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.

在下一行
.bindingMode(RestBindingMode.auto)
上运行springboot Camel和maven时,我遇到了一个错误

我是不是缺少了一些依赖? 我认为这应该不是问题,因为我的
pom.xml
中有下一个依赖项,我不知道为什么会出现这个错误

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>com.example</groupId>
  <artifactId>my-camel-app</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.3.0.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.springboot</groupId>
        <artifactId>camel-spring-boot-dependencies</artifactId>
        <version>3.4.0</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>

    <!-- JMS -->
    <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>
    
    <!-- REST -->
      <dependency>
        <groupId>org.apache.camel.springboot</groupId>
        <artifactId>camel-rest-starter</artifactId>
      </dependency>
       <dependency>
         <groupId>org.apache.camel.springboot</groupId>
         <artifactId>camel-servlet-starter</artifactId>
      </dependency>
      <dependency>
         <groupId>org.apache.camel.springboot</groupId>
         <artifactId>camel-jackson-starter</artifactId>
      </dependency>
      <dependency>
         <groupId>org.apache.camel.springboot</groupId>
         <artifactId>camel-jaxb-starter</artifactId>
     </dependency>
      <dependency>
         <groupId>org.apache.camel.springboot</groupId>
         <artifactId>camel-netty-http-starter</artifactId>
      </dependency>
      <dependency>
         <groupId>org.apache.camel.springboot</groupId>
         <artifactId>camel-jetty-starter</artifactId>
      </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>
    </plugins>
  </build>

</project>

4.0.0
com.example
我的骆驼应用程序
罐子
1.0-快照
驼春靴路线
UTF-8
UTF-8
2.3.0.1发布
org.springframework.boot
spring启动依赖项
${spring.boot version}
聚甲醛
进口
org.apache.camel.springboot
camel-spring引导依赖项
3.4.0
聚甲醛
进口
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧启动机tomcat
org.springframework.boot
弹簧靴起动器下拖
org.springframework.boot
弹簧靴起动器执行器
org.apache.camel.springboot
驼形弹簧靴起动器
org.apache.camel.springboot
骆驼流起动器
org.apache.activemq
artemis jms客户端
org.apache.camel.springboot
骆驼牌jms起动器
org.apache.camel.springboot
骆驼休息起动器
org.apache.camel.springboot
骆驼起动器
org.apache.camel.springboot
骆驼杰克逊起动器
org.apache.camel.springboot
camel-jaxb启动器
org.apache.camel.springboot
camel netty http启动器
org.apache.camel.springboot
驼峰式码头起动器
org.apache.maven.plugins
maven编译器插件
3.8.1
1.8
1.8
org.springframework.boot
springbootmaven插件
${spring.boot version}
重新包装
MySpringBootRouter.java

package com.example;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

/**
 * A simple Camel route that triggers from a timer and calls a bean and prints to system out.
 * <p/>
 * Use <tt>@Component</tt> to make Camel auto detect this route when starting.
 */
@Component
public class MySpringBootRouter extends RouteBuilder {

@Override
    public void configure() {

    String listenAddress = "192.168.0.50";
    int listenPort = 8161;

        restConfiguration()
                .component("servlet")
                //.component("jetty")
                //.component("netty-http")
                .scheme("http")
                .host(listenAddress)
                .bindingMode(RestBindingMode.auto)
                .dataFormatProperty("prettyPrint", "true")
                .port(listenPort);

        rest("/artemis-rest/queues/test")
                .post()
                .produces("application/json")
                .to("direct:route1");
                
        from("direct:route1")
                .convertBodyTo(String.class)
                .log("Boo!");
   }

}
package.com.example;
导入org.apache.camel.builder.RouteBuilder;
导入org.springframework.stereotype.Component;
/**
*一个简单的Camel路由,从计时器触发,调用bean并打印到系统输出。
*

*使用@Component使驼峰在启动时自动检测此路由。 */ @组成部分 公共类MySpringBootRouter扩展RouteBuilder{ @凌驾 public void configure(){ String listenadress=“192.168.0.50”; int listenPort=8161; restConfiguration() .组件(“servlet”) //.组件(“码头”) //.component(“netty http”) .scheme(“http”) .主持人(李斯特) .bindingMode(RestBindingMode.auto) .dataFormatProperty(“prettyPrint”、“true”) .港口(listenPort); rest(“/artemis rest/queues/test”) .post() .products(“应用程序/json”) 。至(“直接:路线1”); 从(“直接:路由1”) .convertBodyTo(String.class) .log(“Boo!”); } }


如果我评论
/.bindingMode(RestBindingMode.auto)
骆驼启动正常。

正如Luca所说,我忘了在myspringbootrower.java中导入RestBindingMode


导入org.apache.camel.model.rest.RestBindingMode

查看您发布的类,您缺少导入org.apache.camel.model.rest.RestBindingMode的功能谢谢。这解决了
.bindingMode(RestBindingMode.auto)
的问题。
package com.example;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

/**
 * A simple Camel route that triggers from a timer and calls a bean and prints to system out.
 * <p/>
 * Use <tt>@Component</tt> to make Camel auto detect this route when starting.
 */
@Component
public class MySpringBootRouter extends RouteBuilder {

@Override
    public void configure() {

    String listenAddress = "192.168.0.50";
    int listenPort = 8161;

        restConfiguration()
                .component("servlet")
                //.component("jetty")
                //.component("netty-http")
                .scheme("http")
                .host(listenAddress)
                .bindingMode(RestBindingMode.auto)
                .dataFormatProperty("prettyPrint", "true")
                .port(listenPort);

        rest("/artemis-rest/queues/test")
                .post()
                .produces("application/json")
                .to("direct:route1");
                
        from("direct:route1")
                .convertBodyTo(String.class)
                .log("Boo!");
   }

}