警告启动 Spring Boot 应用程序 [英] Warning starting the spring boot application

查看:99
本文介绍了警告启动 Spring Boot 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个 SpringBoot 应用程序.但是当我尝试使用 Postman 访问它时,它显示状态为 404 并在控制台上发出警告:

I am trying to write a SpringBoot application. But when I am trying to access it using Postman, it shows Status as 404 and gives a warning on console:

警告 6616 --- [nio-8080-exec-1] o.g.jersey.internal.inject.Providers
:提供者 com.cognizant.insurance.controller.RestServiceController在 SERVER 运行时中注册的未实现任何提供程序适用于 SERVER 运行时的接口.由于约束提供者的配置问题com.cognizant.insurance.controller.RestServiceController 将是忽略.

WARN 6616 --- [nio-8080-exec-1] o.g.jersey.internal.inject.Providers
: A provider com.cognizant.insurance.controller.RestServiceController registered in SERVER runtime does not implement any provider interfaces applicable in the SERVER runtime. Due to constraint configuration problems the provider com.cognizant.insurance.controller.RestServiceController will be ignored.

我的休息控制器是:

@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注解有什么特殊原因吗?如果没有,请尝试将其删除.控制器应该可以在没有此注释的情况下工作.

Is there any special reason for you to use @Provider annotation? If not, try to remove it. Controller should work without this annotation.

@Component 也是如此.这是一个通用构造型注释,表明该类是一个弹簧组件.如果您使用 @Controller,则不需要此注释.

The same is about @Component. This is a general-purpose stereotype annotation indicating that the class is a spring component. If you are using @Controller, you don't need this annotation.

您可以阅读 @Component@Controller 之间的区别 此处.

You can read about differences between @Component and @Controller here.

这篇关于警告启动 Spring Boot 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆