如何仅为Activiti REST端点更改Spring MVC Servlet映射? [英] How do I change the Spring MVC servlet mapping for only Activiti REST endpoints?

查看:126
本文介绍了如何仅为Activiti REST端点更改Spring MVC Servlet映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用Spring Boot和Activiti REST版本5.17.0(使用spring-boot-starter-rest-api)的应用程序。由于应用程序已经拥有自己的REST端点,因此我们希望将Activiti REST端点放在单独的路径中,例如

I am working on an application where we are using Spring Boot and Activiti REST version 5.17.0 (using spring-boot-starter-rest-api). As the application already has REST endpoints of its own, we would like to put the Activiti REST endpoints in a separate path, e.g.


  • www。 example.com:1234/myAppNameHere/bpm-rest/repository/process-definitions/myProcess:1:6

  • www.example.com:1234/myAppNameHere/bpm-rest/runtime/流程实例

我希望我现有的REST端点保持不变,例如

I want my existing REST endpoints to be unchanged, e.g.


  • www.example.com:1234/myAppNameHere/myResource/1234

我能够实现通过配置web.xml文件,在使用Activiti 5.14及其Restlet功能的其他应用程序中使用此功能。

I was able to achieve this functionality in a different application using Activiti 5.14 with its Restlet functionality by configuring the web.xml file:

<servlet>  
  <servlet-name>RestletServlet</servlet-name>  
  <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
  <init-param>
    <param-name>org.restlet.application</param-name>
    <param-value>my.organization.appname.MyAppActivitiRestApplication</param-value>
  </init-param>
</servlet>

<servlet-mapping>
  <servlet-name>RestletServlet</servlet-name>
  <url-pattern>/bpm-rest/*</url-pattern>
</servlet-mapping>

但是,我不确定如何在带有Activiti的Spring Boot / Spring MVC配置中复制此功能REST版本5.17.0(请注意,Activiti在5.16.4中从Restlet切换到Spring MVC)。

However, I am unsure how I would duplicate this functionality with the Spring Boot/Spring MVC configuration with Activiti REST version 5.17.0 (note that Activiti switched from Restlet to Spring MVC in 5.16.4).

我问了类似的问题回到Activiti论坛上,当时我正尝试将其他应用程序升级到Activiti 5.16.4。在该线程中,我被告知可以通过覆盖WebConfigurer类更改servlet映射。但是,在Activiti或Spring MVC中都看不到具有该名称的类。在Spring Boot的 org.springframework.boot.test下有一个,但是我怀疑不是那个。

I asked a similar question a while back on the Activiti Forums when I was attempting to upgrade my other application to Activiti 5.16.4. In that thread I was advised that I could change the servlet mapping "by overriding the WebConfigurer class". However, I do not see a class with that name in either Activiti or Spring MVC. There is one in Spring Boot under "org.springframework.boot.test", but I suspect that's not the one being referred to.

简而言之,我该如何配置Activiti 5.17.0 Spring MVC REST端点使用我的应用程序端点中的应用程序的单独子路径?

In short, how do I configure the Activiti 5.17.0 Spring MVC REST endpoints to use a separate sub-path of my application from my application endpoints?

注意:我试图将此问题发布到 Activiti论坛本身,但似乎没有出现在该系统中,尽管系统声称

Note: I attempted to post this question on the Activiti forums themselves, but it doesn't appear to be showing up there, despite the system claiming that the forum topic was created.

推荐答案

我不熟悉使用新的spring boot功能,我确实知道5.16.4(不知道为什么要在点发行版中这样做),REST API配置已从使用RESTLET更改为Spring MVC。这意味着您将不会看到单个的WebConfigurer类(而不是在使用spring boot时是否具有相同的名称),而不是在web.xml中配置侦听器。

I am not familiar with using the new spring boot features, I do know that as of 5.16.4 (no idea why they did this in a point release) the REST API configuration was changed from using RESTLET to Spring MVC. This means rather than configuring a listener in web.xml you will see a single WebConfigurer class (not sure if it has the same name when using spring boot).

打开该类,您将找到在servlet配置路径中定义的其余映射路径:

If you open that class, you will find the rest mapping path defined in the servlet configuration path:

dispatcherServlet.addMapping( / service / *);

dispatcherServlet.addMapping("/service/*");

说实话,我更喜欢使用restlet方法。

To be honest, I much prefer the restlet approach.

希望这会有所帮助。

这篇关于如何仅为Activiti REST端点更改Spring MVC Servlet映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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