title: is it possible to register route filter in the application.properties config in spring gateway
body: <p>I define a custom filter in spring gateway project, now I found I have to register the custom filter in the code like this:</p>
  <pre><code>@Configuration
  public class GatewayConfig {
  
      private final JwtAuthenticationFilter filter;
  
      public GatewayConfig(JwtAuthenticationFilter filter) {
          this.filter = filter;
      }
  
      @Bean
      public RouteLocator routes(RouteLocatorBuilder builder) {
          return builder.routes()
                  .route(&quot;auth&quot;, r -&gt; r.path(&quot;/auth/**&quot;).filters(f -&gt; f.filter(filter)).uri(&quot;lb://auth&quot;))
                  .route(&quot;music&quot;, r -&gt; r.path(&quot;/music/**&quot;).filters(f -&gt; f.filter(filter)).uri(&quot;lb://dolphin-music&quot;)).build();
      }
  }
  </code></pre>
  <p>if I do not register the custom filter, the filter will not make effect and work as expect. But I already config the route in <code>application.properties</code> like this:</p>
  <pre><code># dolphin music
  spring.cloud.gateway.discovery.locator.enabled=true
  spring.cloud.gateway.discovery.locator.lower-case-service-id=true
  spring.cloud.gateway.routes[0].id=dolphin-music-service
  # forward by ip:port way
  spring.cloud.gateway.routes[0].uri=http://10.107.64.246:11014
  # forward by service name way
  # spring.cloud.gateway.routes[0].uri=lb://
  spring.cloud.gateway.routes[0].predicates[0]=Path=/music/**
  </code></pre>
  <p>I think we should not define the route config both in code and configuration file, what should I do to only register the filter? is there any better way to handle the situation? should I must define the route in code? I think config in file will more flexible.BTW,this is the <code>JwtAuthenticationFilter</code>:</p>
  <pre><code>@Component
  public class JwtAuthenticationFilter implements GatewayFilter {
  
      @Value(&quot;${dolphin.gateway.jwt.verify:true}&quot;)
      private boolean jwtVerfiy;
  
      final static List&lt;String&gt; apiEndpoints = List.of(&quot;/register&quot;, &quot;/login&quot;);
  
      final static Predicate&lt;ServerHttpRequest&gt; isApiSecured = r -&gt; apiEndpoints.stream()
              .noneMatch(uri -&gt; r.getURI().getPath().contains(uri));
  
      @Override
      public Mono&lt;Void&gt; filter(ServerWebExchange exchange, GatewayFilterChain chain) {
          
          return chain.filter(exchange);
      }
  }
  </code></pre>
  <p>I tried to add <code>MyFilterFactory</code> like this:</p>
  <pre><code>@Component
  public class MyFilterFactory extends AbstractGatewayFilterFactory&lt;MyFilterFactory.Config&gt; {
  
      @Autowired
      private JwtAuthenticationFilter jwtAuthenticationFilter;
  
      public MyFilterFactory() {
          super(Config.class);
      }
  
      @Override
      public GatewayFilter apply(Config config) {
          return jwtAuthenticationFilter; 
      }
  
      public static class Config {
      }
  
  }
  </code></pre>
  <p>and define in route factory in <code>application.properties</code> like this:</p>
  <pre><code>spring.cloud.gateway.routes[0].filters[0]=MyFilterFactory
  </code></pre>
  <p>the problem is that the request did not enter the <code>JwtAuthenticationFilter</code> I am defined.</p>