[英]Warning starting the spring boot application
我正在嘗試編寫一個SpringBoot應用程序。 但是,當我嘗試使用Postman訪問它時,它顯示Status為404並在控制台上發出警告:
WARN 6616-[nio-8080-exec-1] ogjersey.internal.inject.Providers
:在SERVER運行時中注冊的提供者com.cognizant.insurance.controller.RestServiceController不實現適用於SERVER運行時的任何提供者接口。 由於約束配置問題,提供程序com.cognizant.insurance.controller.RestServiceController將被忽略。
我的休息控制器是:
@Component
@Provider
@Controller
@RequestMapping(value="/api", produces="application/json")
public class RestServiceController {
@Autowired
private CordaRPCService cordaRPCService;
@Value(value = "${node.PartyA.rpc.hostport}")
private String nodeRpcHostAndPort;
@Value(value = "${nodename}")
private String nodeName;
CordaRPCOps rpcService = null;
String inDateFormat = "dd/MM/yyyy";
PolicyState policy;
@RequestMapping(value="/createpolicy", method=RequestMethod.GET)
public String doTradeCreditPolicy() {
return "Hello";
}
我的項目結構:
主文件:
package com.cognizant.insurance;
@SpringBootApplication
@EnableScheduling
@EnableCaching
@ComponentScan("com.cognizant.insurance")
public class Application extends SpringBootServletInitializer {
public static void main(final String[] args) {
new Application()
.configure(new SpringApplicationBuilder(Application.class))
.run(args);
}
}
您使用@Provider
注釋是否有任何特殊原因? 如果不是,請嘗試將其刪除。 控制器應在沒有此注釋的情況下工作。
@Component
。 這是一個通用的構造型注釋,指示該類是彈簧組件。 如果使用@Controller
,則不需要此注釋。
您可以在此處了解@Component
和@Controller
之間的區別。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.