我目前正在使用的Spring项目工作。我有以下:
<!-- 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>
当我试图对localhost:8080/urlTest做卷曲时,它给了我一个404。
后来我注意到我们有一个泽西资源配置类,在这个类中,我们必须注册使用@Path注释定义的所有路径,所以我假设404错误是因为我没有在泽西注册该路径。但我不确定,因为我以前从未在泽西岛工作过。
@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);
}
}如何在中注册网关"/urlTest“中定义的路径?
提前谢谢你。
发布于 2016-10-24 09:33:24
最后,我只需将路径添加到ServletProperties.FILTER_STATIC_CONTENT_REGEX of ResourceConfig中即可。
https://stackoverflow.com/questions/40136125
复制相似问题