Java 为什么在使用带有@Provider注释的Spring时仍然需要resteasy.providers?

Java 为什么在使用带有@Provider注释的Spring时仍然需要resteasy.providers?,java,spring,jax-rs,web.xml,resteasy,Java,Spring,Jax Rs,Web.xml,Resteasy,我有一个使用Spring的Resteasy应用程序,它包含ContainerRequestFilter和ContainerResponseFilter实现,并用@Provider注释。应用程序正在使用Resteasy的3.0-beta-6版本 将这些过滤器添加到web.xml中的resteasy.providerscontext参数时,它们会按预期工作,如下所示: <context-param> <param-name>resteasy.providers&l

我有一个使用Spring的Resteasy应用程序,它包含
ContainerRequestFilter
ContainerResponseFilter
实现,并用
@Provider
注释。应用程序正在使用Resteasy的
3.0-beta-6
版本

将这些过滤器添加到web.xml中的
resteasy.providers
context参数时,它们会按预期工作,如下所示:

<context-param>
      <param-name>resteasy.providers</param-name>
      <param-value>foo.filter.LoggingRequestFilter,
                   foo.filter.LoggingResponseFilter</paramvalue>
</context-param> 

resteasy.providers
foo.filter.LoggingRequestFilter,
foo.filter.LoggingResponseFilter
如果我从这里移除过滤器,它们将不再被调用

我假设这些提供者在使用
org.jboss.Resteasy.plugins.spring.SpringContextLoaderListener
时会自动向Resteasy注册。对我来说奇怪的是,它适用于Resteasy早期版本中的
预截取器
实现,并且在v3中仍然有效,但是过滤器和异常标记不会自动注册

问题
  • 如果类用
    @Provider
    注释并由Spring扫描,为什么需要使用
    resteasy.providers
    上下文参数
  • 是否有一种编程方式可以在运行时设置这些提供程序
    为了让Spring扫描提供者,我必须在Spring Java配置类的
    @ComponentScan
    中添加
    includeFilters
    参数

    @ComponentScan(value = "com.foo", 
                   includeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, value = Provider.class))
    
    您还可以使用
    @Component
    @Provider
    对它们进行注释,Spring将确保在使用Resteasy的
    SpringContextLoaderListener
    时,Resteasy能够检测到它们