嗨,我使用的是与骆驼的回弹,我的路线是正确的开始,但不能触发rest,因为我不能找到他们。
pom.xml
<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.camel</groupId>
<artifactId>spring-camel</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-camel</name>
<description>Demo project for Spring Boot</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<camel.version>2.21.0</camel.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-restlet</artifactId>
<version>${camel.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
application.properties
camel.springboot.xmlRoutes = true
camel.springboot.xmlRoutes = classpath:xml-route/*.xml
camel.springboot.main-run-controller=true
camel.springboot.xmlRests = true
camel.springboot.xmlRests = classpath:xml-rest/*.xml
server.port = 8084
spring.application.name = spring-camel Springboot主类:
@SpringBootApplication
@EnableAutoConfiguration
public class SpringCamelApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCamelApplication.class, args);
}
} REST路由:
<rests xmlns="http://camel.apache.org/schema/spring">
<rest id="rest-route">
<get uri="/test">
<to uri="direct:test"/>
</get>
</rest>
</rests>应用程序启动后的日志:
2018-05-28 12:34:46.178 INFO 4852 --- [ main] o.a.camel.spring.SpringCamelContext : StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2018-05-28 12:34:46.211 INFO 4852 --- [ main] o.a.camel.component.file.FileEndpoint : Endpoint is configured with noop=true so forcing endpoint to be idempotent as well
2018-05-28 12:34:46.211 INFO 4852 --- [ main] o.a.camel.component.file.FileEndpoint : Using default memory based idempotent repository with cache max size: 1000
2018-05-28 12:34:46.357 INFO 4852 --- [ main] o.a.camel.spring.boot.RoutesCollector : Starting CamelMainRunController to ensure the main thread keeps running
2018-05-28 12:34:46.361 INFO 4852 --- [ main] o.a.camel.spring.SpringCamelContext : Route: first-route started and consuming from: direct://test
2018-05-28 12:34:46.374 INFO 4852 --- [ main] o.a.camel.spring.SpringCamelContext : Route: second-route started and consuming from: file://E://inputFolder?noop=true
2018-05-28 12:34:46.384 INFO 4852 --- [ main] o.a.camel.spring.SpringCamelContext : Route: route1 started and consuming from: restlet:///test?restletMethods=GET
2018-05-28 12:34:46.385 INFO 4852 --- [ main] o.a.camel.spring.SpringCamelContext : Total 3 routes, of which 3 are started
2018-05-28 12:34:46.388 INFO 4852 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.21.0 (CamelContext: camel-1) started in 0.471 seconds
2018-05-28 12:34:46.395 INFO 4852 --- [ main] c.c.springcamel.SpringCamelApplication : Started SpringCamelApplication in 3.543 seconds (JVM running for 3.878)很明显,它说‘route1是从:restlet:/test?restletMethods=GET开始和消费的’,但是当我调用http://localhost:8084/test时,它说它是不可访问的。
急需帮助,提前谢了。
发布于 2018-05-29 20:58:32
最后,它成功地在spring上下文中添加了rest配置。刚刚添加了下面的代码
@Bean
public RestConfiguration getRest()
{
RestConfiguration restconfig=new RestConfiguration();
restconfig.setPort(8081);
restconfig.setComponent("restlet");
//restconfig.setHost("localhost");
restconfig.setContextPath("/api");
restconfig.setBindingMode("auto");
return restconfig;
}https://stackoverflow.com/questions/50569638
复制相似问题