我正在尝试一个简单的Rest服务,使用apache camel和get作为超文本传输协议动词。
package com.ApacheCamelTraining.camelmicroservicea.routes.b;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
@Component
public class MyFileRouter extends RouteBuilder{
@Override
public void configure() throws Exception {
restConfiguration().component("servlet")
.host("localhost").port(8080);
rest("say/hello")
.get().route().transform().constant("Hello World!")
//.post().to("file:files/sayHello")
;
from("file:files/input")
.log("${body}")
.to("file:files/output");
}
}
我正在《邮递员》中尝试这一点:<代码>http://localhost:8080/demo/camel/say/hello由于应用程序中的上下文路径,添加了“demo”。属性文件,注意在添加以下内容之前,此文件为空:
camel.springboot.main-run-controller=true
server.servlet.context-path=/demo
“camel”是因为CamelServlet默认设置为“/camel”
请查找以下我的依赖项:camel-core:3.11.1 camel-servlet:3.11.1 camel-service-starter:3.11.1 camel-servlet-starter:3.0.0-RC3 camel-http-common:3.11.1 camel-spring-boot-starter:3.11.1
最后,这是我运行应用程序时控制台显示的内容
2021-09-13 11:02:06.117 INFO 20392 --- [ restartedMain] c.A.c.CamelMicroserviceAApplication : Starting CamelMicroserviceAApplication using Java 11.0.12 on E210 with PID 20392 (D:\Users\User\MyFiles\Apache Camel github\Apache Camel Youtube Training\camel-microservice-a\target\classes started by User in D:\Users\User\MyFiles\Apache Camel github\Apache Camel Youtube Training\camel-microservice-a)
2021-09-13 11:02:06.117 INFO 20392 --- [ restartedMain] c.A.c.CamelMicroserviceAApplication : No active profile set, falling back to default profiles: default
2021-09-13 11:02:06.302 INFO 20392 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-09-13 11:02:06.303 INFO 20392 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-09-13 11:02:06.303 INFO 20392 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.52]
2021-09-13 11:02:06.330 INFO 20392 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/demo] : Initializing Spring embedded WebApplicationContext
2021-09-13 11:02:06.330 INFO 20392 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 212 ms
2021-09-13 11:02:06.422 INFO 20392 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2021-09-13 11:02:06.424 INFO 20392 --- [ restartedMain] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2021-09-13 11:02:06.432 INFO 20392 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/demo'
2021-09-13 11:02:06.455 INFO 20392 --- [ restartedMain] c.s.b.CamelSpringBootApplicationListener : Starting CamelMainRunController to ensure the main thread keeps running
2021-09-13 11:02:06.456 INFO 20392 --- [ restartedMain] o.a.c.impl.engine.AbstractCamelContext : Routes startup summary (total:2 started:2)
2021-09-13 11:02:06.456 INFO 20392 --- [ restartedMain] o.a.c.impl.engine.AbstractCamelContext : Started route32 (file://files/input)
2021-09-13 11:02:06.456 INFO 20392 --- [ restartedMain] o.a.c.impl.engine.AbstractCamelContext : Started route33 (rest://get:say/hello)
2021-09-13 11:02:06.456 INFO 20392 --- [ restartedMain] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.11.1 (camel-15) started in 20ms (build:2ms init:17ms start:1ms)
2021-09-13 11:02:06.456 INFO 20392 --- [ restartedMain] c.A.c.CamelMicroserviceAApplication : Started CamelMicroserviceAApplication in 0.35 seconds (JVM running for 1966.925)
2021-09-13 11:02:06.457 INFO 20392 --- [ restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation unchanged
2021-09-13 11:03:34.724 INFO 20392 --- [nio-8080-exec-5] o.a.c.c.C.[Tomcat].[localhost].[/demo] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-09-13 11:03:34.724 INFO 20392 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-09-13 11:03:34.726 INFO 20392 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : Completed initialization in 0 ms
这是错误:
{
"timestamp": "2021-09-13T12:55:34.581+00:00",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/demo/say/hello"
}
谢谢你,非常感谢你的帮助!
要设置上下文路径,您必须使用以下属性:
camel.servlet.mapping.context-path
或在yaml中:
camel:
servlet:
mapping:
context-path:
看见https://camel.apache.org/components/3.12.x/servlet-component.html#_sb_option_camel_servlet_mapping_context-路径
我假设你从骆驼2迁移到骆驼3是因为骆驼2的属性
camel.component.servlet.mapping.context-path
事实证明,不同的骆驼示范回购协议对我非常有帮助:
我在这里找到了针对您的具体案例的解决方案:https://github.com/apache/camel-spring-boot-examples/tree/main/rest-swagger
我试图在JMeter中使用HTTP请求采样器来连接单个API请求,其中API有效负载有5000多行。在检查了请求有效负载和头之后,我尝试在JMeter中点击,但它无法返回响应,并抛出了“SocketException:Connection Reset”错误。 浏览了这个博客https://www.xtivia.com/blog/fixing-jmeter-socket-errors/&在进行了这里
这是我要点击的url,以便在postman和browser中张贴附件 请协助或建议我如何继续
第一次在这里问问题,如果这是错误的,我道歉-我会好起来的! 我跟着一个Vue。我试图通过“@import”../node_modules/Bulma/Bulma.sass”文件安装并调用Bulma。 我可以查看我的vue“主页”,但一旦我将“lang=sass”添加到我的样式标记中,我就会不断收到以下错误: "编译失败。 ./节点\模块/css加载器?{“sourceMap”:true}/节点\模
我跟着教程上了课 https://developer.atlassian.com/server/framework/atlassian-sdk/create-a-confluence-hello-world-macro/ 但当我尝试运行atlas并打开localhost:1990/confluence时,我得到了一个404错误。 我已经多次检查了我的java和sdk版本。Atlas 6.3.10
我编写了一些请求映射,并使用JPA将Spring Boot应用程序连接到Postgresql DB。但是,当我尝试调用API时,我会得到以下消息:。我试着在调用API时打印一条消息,它可以工作,所以我想这可能与JPA连接有关?(我还使用SQL Shell测试了数据库和凭据是否良好,它们都是可以的) 我的模型: 我的控制器: 最后,我的应用程序属性:
问题内容: 当我尝试在Chrome中运行测试时出现此错误: 初始化方法AutomationUsingSelenium.SmuladorChrome.MyTestInitialize引发异常。OpenQA.Selenium.DriverServiceNotFoundException:OpenQA.Selenium.DriverServiceNotFoundException 原因是什么? 问题答案