1

I'm creating different Filter @Bean, and would like to enforce the execution of a specific filter before the other filter:

@Bean
@Order(1)
public Filter getLoggingUuidFilter() {
    return new Filter() {
        //...
    };
}

@Bean
@Order(2)
public Filter getLoggingRequestFilter() {
    return new CommonsRequestLoggingFilter();
}

Result: Filter2 executes before Filter1. Why?

membersound
  • 81,582
  • 193
  • 585
  • 1,120
  • Ok, so `@Order` is not for ordering the filter, but one has to additionally create a `FilterRegistrationBean` and `filter.setOrder(Ordered.HIGHEST_PRECEDENCE);`. – membersound Feb 05 '16 at 10:51

1 Answers1

-2

from spring documentation of @Order

Annotation-based ordering is supported for specific kinds of components only — for example, for annotation-based AspectJ aspects. Ordering strategies within the Spring container, on the other hand, are typically based on the Ordered interface in order to allow for programmatically configurable ordering of each instance

hahn
  • 3,588
  • 20
  • 31