简体   繁体   中英

Jersey resource config and Spring integration http:inbound-gateway

I am currently working in a Spring Boot project with Spring Integration flow. I have the following Spring Integration xml:

<!-- CHANNELS -->
<int:channel id="channelInput"/>
<int:channel id="channelOutput"/>

<int-http:inbound-gateway id="http-inbound-gateway"
                          request-channel="channelInput"
                          reply-channel="channelOutput"
                          supported-methods="GET"
                          path="/urlTest"
                          >
    <int-http:request-mapping consumes="application/json"
                              produces="application/json"/>

</int-http:inbound-gateway>


<int:service-activator input-channel="channelInput"
                       ref="serviceClassImpl"
                       method="testMethod"
                       output-channel="channelOutput">
</int:service-activator>

When I tried to do a curl against localhost:8080/urlTest it gives me a 404.

Later I noticed we have a Jersey resource config class, in which one we have to register all the paths defined with the @Path annotation, so I suppose that 404 error is because I don't register that path in Jersey. But I am not sure, because I have never worked before with Jersey.

@Component
public class ApplicationJerseyConfig extends ResourceConfig {
  public ApplicationJerseyConfig() {
    property(ServletProperties.FILTER_STATIC_CONTENT_REGEX,"/(info|browser/.*|api/(swagger.json|info)?|.*/api-docs.?|console/.*|configuration/.*|.*.html|.*.jpg|.*.gif|.*.png|.*.map|.*.js|.*.css|.*.ttf)?");
    register(TestRest.class);
    }
}

How can I register the path defined in the gateway, "/urlTest", in the Jersey Resource Config?

Thank you in advance.

终于工作了,我只需要将路径添加到ResourceConfig的ServletProperties.FILTER_STATIC_CONTENT_REGEX中即可。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM