@Component public class FormData. keys {
private final Environment env;
public BookRoute(Environment env) {
this.env = env;
}
public void configure() throws Exception {
restConfiguration()
.contextPath(env.getProperty("camel.component.servlet.mapping.contextPath", "/rest/*"))
.apiContextPath("/api-doc")
.apiProperty("api.title", "Spring Boot Camel Postgres Rest API.")
.apiProperty("api.version", "1.0")
.apiProperty("cors", "true")
.apiContextPath("doc-api")
.port(env.getProperty("server.port", "8080"))
.bindingMode(RestBindingMode.json);
rest("/book")
.consumes(MediaType.APPLICATION_JSON_VALUE)
.produces(MediaType.APPLICATION_JSON_VALUE)
.get("/{name}").route()
.to("{{route.findBookByName}}")
.endRest()
.get("/").route()
.to("{{route.findAllBooks}}")
.endRest()
.post("/").route()
.marshal().json()
.unmarshal(getJacksonDataFormat(Book.class))
.to("{{route.saveBook}}")
.endRest()
.delete("/{bookId}").route()
.to("{{route.removeBook}}")
.end();
from("{{route.findBookByName}}")
.log("Received header : ${header.name}")
.bean(BookService.class, "findBookByName(${header.name})");
from("{{route.findAllBooks}}")
.bean(BookService.class, "findAllBooks");
from("{{route.saveBook}}")
.log("Received Body ${body}")
.bean(BookService.class, "addBook(${body})");
from("{{route.removeBook}}")
.log("Received header : ${header.bookId}")
.bean(BookService.class, "removeBook(${header.bookId})");
}
private JacksonDataFormat getJacksonDataFormat(Class<?> unmarshalType) {
JacksonDataFormat format = new JacksonDataFormat();
format.setUnmarshalType(unmarshalType);
return format;
}
}
上面的代码在“<camel.version>3.3.0</camel.version>“下运行良好,但当我将版本更改为“<camel.version>4.0.0-M3</camel.version>“时,我在routebuilder类中的“.route()”方法出现错误,说“方法route()对于类型RestDefinition是未定义的”如何解决这个问题?
1条答案
按热度按时间bfnvny8b1#
请参阅Camel升级指南,了解从3.16开始的rest-tool更改https://camel.apache.org/manual/camel-3x-upgrade-guide-3_16.html#_rest_dsl