使用配置文件设置不同的上下文路径

时间:2019-08-13 15:51:23

标签: java spring-boot

为Webservice和Rest设置不同的上下文路径

我有一个包含Webservices和Rest服务实现的应用程序,我正在寻找一种解决方案,以使用yml / properties文件为Webservices和Rest服务设置上下文路径

如何配置servlet调度程序正常工作?

我想要:

localhost:8080/ws/* - webservice
localhost:8080/web/* - MVC components
  servlet:
    context-path: "/ws"

它为Web服务和休息服务全局设置,如何在不进行编程的情况下使其彼此独立?

1 个答案:

答案 0 :(得分:0)

使用Spring Boot(通过Spring Starter Web),您可以通过@RequestMapping注释实现您的要求。

您可以将@RequestMapping(value =“ / ws”)放在每个rest控制器的类声明中,并将@RequestMapping(value =“ / web”)用于Web控制器。

对于rest和Web控制器,您可以使用其他注释来指定方法路径,即@GetMapping(value =“ / methodPath”)。

a