[英]I am running my application which is based java spring boot framework. but getting this error. Can you help me to resolve this error?
I am running my application which is based java spring boot framework.我正在运行基于 java spring 引导框架的应用程序。 basically i have more then one microservices and I want them to communicate using http rest.
基本上我有不止一个微服务,我希望它们使用 http rest 进行通信。 but getting this error.
但得到这个错误。 Can you help me to resolve this error??
你能帮我解决这个错误吗?
'''2022-01-10 10:31:52.834 INFO 13740 --- [ main] com.accounts.account.AccountApplication: Started AccountApplication in 53.129 seconds (JVM running for 57.978) 2022-01-10 10:31:53.259 DEBUG 13740 --- [ main] osbaApplicationAvailabilityBean: Application availability state LivenessState changed to CORRECT 2022-01-10 10:31:53.274 DEBUG 13740 --- [ main] osbaApplicationAvailabilityBean: Application availability state ReadinessState changed to ACCEPTING_TRAFFIC 2022-01-10 10:32:42.838 INFO 13740 --- [nio-8080-exec-1] oac.c.C.[Tomcat].[localhost].[/]: Initializing Spring DispatcherServlet 'dispatcherServlet' 2022-01-10 10:32:42.838 INFO 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Initializing Servlet 'dispatcherServlet' 2022-01-10 '''2022-01-10 10:31:52.834 INFO 13740 --- [main] com.accounts.account.AccountApplication:在 53.129 秒内启动 AccountApplication(JVM 运行 57.978)2022-01-10 10:31:52。 DEBUG 13740 --- [ main] osbaApplicationAvailabilityBean: Application availability state LivenessState changed to CORRECT 2022-01-10 10:31:53.274 DEBUG 13740 --- [ main] osbaApplicationAvailabilityBean: Application availability state ReadinessState changed to ACCEPTING_TRAFFIC 2022-01-10 10 :32:42.838 INFO 13740 --- [nio-8080-exec-1] oac.c.C.[Tomcat].[localhost].[/]: Initializing Spring DispatcherServlet 'dispatcherServlet' 2022-01-10 10:32 :42.838 INFO 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet:初始化 Servlet 'dispatcherServlet' 2022-01-10 10:32:42.839 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Detected StandardServletMultipartResolver 2022-01-10 10:32:42.840 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Detected AcceptHeaderLocaleResolver 2022-01-10 10:32:42.841 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Detected FixedThemeResolver 2022-01-10 10:32:42.848 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Detected org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@72a61e61 2022-01-10 10:32:42.850 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Detected org.springframework.web.servlet.support.SessionFlashMapManager@742dbac8 2022-01-10 10:32:42.851 DEBUG 13740 --- [nio-8080-exec-1] osZ2
10:32:42.839 调试 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: 检测到 StandardServletMultipartResolver 2022-01-10 10:32:42.840 调试 13740-80 --- ] osweb.servlet.DispatcherServlet: Detected AcceptHeaderLocaleResolver 2022-01-10 10:32:42.841 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Detected FixedThemeResolver 2022-01-10 10:32: 42.848 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Detected org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@72a61e61 2022-01-10 10:32:42.850 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Detected org.springframework.web.servlet.support.SessionFlashMapManager@742dbac8 2022-01-10 10:32:42.851 DEBUG 13740 --- [nio-8080-exec -1] osZ2 567A5EC9705EB7AC2C984033E06189DZ.servlet.DispatcherServlet: enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data 2022-01-10 10:32:42.852 INFO 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Completed initialization in 13 ms 2022-01-10 10:32:42.942 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: GET "/", parameters={} 2022-01-10 10:32:43.030 DEBUG 13740 --- [nio-8080-exec-1] oswshandler.SimpleUrlHandlerMapping: Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]] 2022-01-10 10:32:43.046 DEBUG 13740 --- [nio-8080-exec-1] ojsOpenEntityManagerInViewInterceptor: Opening JPA EntityManager in OpenEntityManagerInViewInterceptor 2022-01-10 10:32:43.069 DEBUG 13740 --- [nio-8080-exec-1]
567A5EC9705EB7AC2C984033E06189DZ.servlet.DispatcherServlet:enableLoggingRequestDetails='false':请求参数和标头将被屏蔽以防止潜在敏感数据的不安全记录 2022-01-10 10:32:42.852 INFO 13740 --- [nio-8080-exec-1 ] osweb.servlet.DispatcherServlet: Completed initialization in 13 ms 2022-01-10 10:32:42.942 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: GET "/", parameters={ 2022-01-10 10:32:43.030 调试 13740 --- [nio-8080-exec-1] oswshandler.SimpleUrlHandlerMapping:映射到 ResourceHttpRequestHandler [classpath [META-INF/resources/],classpath [resources/],classpath [静态/],类路径 [public/],ServletContext [/]] 2022-01-10 10:32:43.046 调试 13740 --- [nio-8080-exec-1] ojsOpenEntityManagerInViewInterceptor:在 OpenEntityManagerInViewInterceptor 中打开 JPA EntityManager -10 10:32:43.069 调试 13740 --- [nio-8080-exec-1] oswsr.ResourceHttpRequestHandler: Resource not found 2022-01-10 10:32:43.071 DEBUG 13740 --- [nio-8080-exec-1] ojsOpenEntityManagerInViewInterceptor: Closing JPA EntityManager in OpenEntityManagerInViewInterceptor 2022-01-10 10:32:43.072 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Completed 404 NOT_FOUND 2022-01-10 10:32:43.144 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: "ERROR" dispatch for GET "/error", parameters={} 2022-01-10 10:32:43.229 DEBUG 13740 --- [nio-8080-exec-1] swsmmaRequestMappingHandlerMapping: Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse) 2022-01-10 10:32:43.231 DEBUG 13740 --- [nio-8080-exec-1] ojsOpenEntityManagerInViewInterceptor: Opening JPA
oswsr.ResourceHttpRequestHandler: Resource not found 2022-01-10 10:32:43.071 DEBUG 13740 --- [nio-8080-exec-1] ojsOpenEntityManagerInViewInterceptor: Closing JPA EntityManager in OpenEntityManagerInViewInterceptor 2022-01-10 10:32:43.072 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Completed 404 NOT_FOUND 2022-01-10 10:32:43.144 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet : GET "/error" 的 "ERROR" dispatch, parameters={} 2022-01-10 10:32:43.229 DEBUG 13740 --- [nio-8080-exec-1] swsmmaRequestMappingHandlerMapping: 映射到 org.springframework.boot。 autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse) 2022-01-10 10:32:43.231 DEBUG 13740 --- [nio-8080-exec-1] ojsOpenEntityManagerInViewInterceptor: Opening JPA EntityManager in OpenEntityManagerInViewInterceptor 2022-01-10 10:32:43.750 DEBUG 13740 --- [nio-8080-exec-1] oswsvContentNegotiatingViewResolver: Selected 'text/html' given [text/html, text/html;q=0.8] 2022-01-10 10:32:43.790 DEBUG 13740 --- [nio-8080-exec-1] ojsOpenEntityManagerInViewInterceptor: Closing JPA EntityManager in OpenEntityManagerInViewInterceptor 2022-01-10 10:32:43.791 DEBUG 13740 --- [nio-8080-exec-1] osweb.servlet.DispatcherServlet: Exiting from "ERROR" dispatch, status 404'''
OpenEntityManagerInViewInterceptor 中的 EntityManager 2022-01-10 10:32:43.750 调试 13740 --- [nio-8080-exec-1] oswsvContentNegotiatingViewResolver:给定 [text/html, text/html;q=0.8] 2022 -01-10 10:32:43.790 DEBUG 13740 --- [nio-8080-exec-1] ojsOpenEntityManagerInViewInterceptor: 关闭 JPA EntityManager 在 OpenEntityManagerInViewInterceptor 2022-01-10 10:32:40.791 exec-1] osweb.servlet.DispatcherServlet:退出“错误”调度,状态 404'''
From the code, it seems you are trying to retrieve an account based on the customer id.从代码中,您似乎正在尝试根据客户 ID 检索帐户。 In that case, it will be @GetMapping and not @PostMapping ( at line 12).
在这种情况下,它将是 @GetMapping 而不是 @PostMapping(在第 12 行)。 Also, in case of get, we pass the variables in the url and not in the request body.
此外,在获取的情况下,我们在 url 中传递变量,而不是在请求正文中。 As a coding practice, the className should start with a capital letter ( the return type of your method should be Account and not accounts )
作为一种编码习惯,className 应该以大写字母开头(方法的返回类型应该是 Account 而不是 accounts)
@GetMapping("/myAccount/{id}
public Account AccountsGetAccountDetails(@PathVariable String id ) {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.