Class JuneauRestAutoConfiguration

java.lang.Object
org.apache.juneau.rest.server.springboot.JuneauRestAutoConfiguration

@AutoConfiguration @ConditionalOnProperty(name="juneau.rest.auto-register", havingValue="true", matchIfMissing=false) public class JuneauRestAutoConfiguration extends Object
Opt-in Spring Boot auto-configuration that mounts every RestServlet bean at its self-declared top-level path without an explicit ServletRegistrationBean per servlet.
Activation:

Gated behind the property juneau.rest.auto-register=true (no default — matchIfMissing=false); when the property is absent or any value other than true, this auto-configuration contributes nothing and servlet registration stays fully manual. Set it in application.properties / application.yaml:

juneau.rest.auto-register=true

Behavior:

When active, a single ServletContextInitializer bean walks all RestServlet beans in the application context and, for each one:

  1. Skips it if its instance is already wired into a manual ServletRegistrationBean (no double-mounts — explicit registrations always win).
  2. Resolves its mount paths via RestContext.resolveTopLevelPaths(...) (reading the top-level paths() / getPaths() chain — not path()), using the application's registered BeanStore for SVL resolution.
  3. Registers the servlet at each resolved path. A servlet that resolves to no top-level paths is skipped (it is presumably composed as a child or mounted some other way).
See Also:
Since:
10.0.0
  • Constructor Details

  • Method Details

    • juneauRestAutoRegistrar

      @Bean public org.springframework.boot.web.servlet.ServletContextInitializer juneauRestAutoRegistrar(org.springframework.context.ApplicationContext appContext)
      Contributes the auto-registration hook.
      Parameters:
      appContext - The Spring application context (source of RestServlet beans, existing ServletRegistrationBean beans, and the BeanStore).
      Returns:
      A ServletContextInitializer that mounts un-registered Juneau servlets.