问题
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/process-instances
I want my existing REST endpoints to be unchanged, e.g.
- www.example.com:1234/myAppNameHere/myResource/1234
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>
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).
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.
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?
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.
回答1:
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).
If you open that class, you will find the rest mapping path defined in the servlet configuration path:
dispatcherServlet.addMapping("/service/*");
To be honest, I much prefer the restlet approach.
Hope this helps.
来源:https://stackoverflow.com/questions/28351584/how-do-i-change-the-spring-mvc-servlet-mapping-for-only-activiti-rest-endpoints