我的SpringBoot Camel应用程序正在运行,并且已启动,我尝试访问“ http:// localhost:8088 / employeeCall”,但是当我命中端点并得到“状态”:404,“错误”时: “未找到”。
'''
@SpringBootApplication
公共类SpringBootHelloWorldApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootHelloWorldApplication.class, args);
}
@Bean
ServletRegistrationBean servletRegistrationBean() {
ServletRegistrationBean servlet = new ServletRegistrationBean(new CamelHttpTransportServlet(),
"/*");
servlet.setName("CamelServlet");
return servlet;
路线
@Component 公共类MyRoute扩展了RouteBuilder {
JacksonDataFormat jsonDataFormat = new JacksonDataFormat(Employee.class);
@Override
public void configure() throws Exception {
//http://localhost:8088/employeeCall trying this url
restConfiguration()
//.contextPath("/test/v1")
.bindingMode(RestBindingMode.json)
.skipBindingOnErrorCode(false);
// digital will be acess
rest().id("restCall")
.post("/employeeCall")
.skipBindingOnErrorCode( false)
.produces(MediaType.APPLICATION_JSON_VALUE)
.type(Employee.class)
.route()
.routeId("route_1")
.streamCaching()
.process(new MyProcessor())
.log("Came here")
.to("direct:postEmployee")
.end();
// access from bancs
/*
* from("direct:postEmployee") .process(new CreateEmployeeProcessor())
* .marshal(jsonDataFormat) .setHeader(Exchange.HTTP_METHOD, simple("POST"))
* .setHeader(Exchange.CONTENT_TYPE,
* constant("application/json")).to("http://localhost:8080/employee")
* .process(new MyProcessor()) .log("Came here") .end();
*/
POM
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-servlet-starter</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
<version>2.19.0</version>
</dependency>
</dependencies>
URL
http:// localhost:8088 / employeeCall
请求
{ “ empId”:444, “ name”:“ pallavi”, “名称”:“老师”, “薪水”:444.00 }
响应
{ “时间戳记”:1595517616041, “状态”:404, “错误”:“未找到”, “ message”:“无可用消息”, “路径”:“ / employeeCall” }
堆栈: