2 回答

TA贡献1813条经验 获得超2个赞
不确定它是否有效,但您可以尝试这种可能的解决方法:强制使用 servlet 组件的三个不同实例,以便调用 setter 不会影响所有实例。
CDI版本(但原则仍然是春季)
public class ServletFactory {
@Produces
@ApplicationScoped
@Named("servlet1")
public ServletComponent propertiesComponent() {
ServletComponent component = new ServletComponent();
... // Customize instance here
return component;
}
@Produces
@ApplicationScoped
@Named("servlet2")
public ServletComponent propertiesComponent() {
ServletComponent component = new ServletComponent();
... // Customize instance here
return component;
}
@Produces
@ApplicationScoped
@Named("servlet3")
public ServletComponent propertiesComponent() {
ServletComponent component = new ServletComponent();
... // Customize instance here
return component;
}
当然,您必须参考正确的名称:
restConfiguration().component("servlet1")

TA贡献1863条经验 获得超2个赞
有很多方法可以通过 Apache Camel 中的 rest dsl 提供配置。因此,我花了很多时间进行调试以找出,如果你想拥有多个,就没有机会(在2.21.5中)选择要使用的servlet。
问题在于,骆驼一方面只支持唯一的“servlet”组件,所以如果添加“servlet1”ServletComponent也无济于事,它最终还是会用“servlet”。
虽然您可以指定许多 RestConfigurations,但将选择“servlet”的唯一配置。
如果你尝试使用 RestEndpoint 的查询部分,那么问题在于,创建的正确设置了 servletNames 的 ServletEndpoints 无论如何都会与它们的 uri 发生冲突:“servlet:/health?httpMethodRestrict=GET”,因此你将只有一个...
对于 REST,我需要切换到 Spring :(
添加回答
举报