From 7fc612ed6cea5d87e49b3d815abd6c86f4101b36 Mon Sep 17 00:00:00 2001 From: seonwoo_jung Date: Tue, 26 May 2026 12:29:22 +0900 Subject: [PATCH] Make WebProperties and WebMvcProperties optional in SwaggerConfig. Fixes #3288 The webmvc-ui starter's SwaggerWebMvcConfigurer bean directly injects WebProperties and WebMvcProperties since 2.8.15 (commit f09afb9, which introduced the WebJar resource handler refactor for #3146). Spring Boot's WebMvcAutoConfiguration normally provides both beans, but applications that disable that auto-configuration (e.g. plain Spring MVC apps that configure the web layer manually) suddenly fail to start with UnsatisfiedDependencyException when upgrading from 2.8.14 to 2.8.16. Switch the bean parameters to ObjectProvider so they are looked up lazily, falling back to default-constructed instances when the beans are absent. The default WebProperties enables resource mappings and the default WebMvcProperties exposes "/webjars/**" as the WebJar path pattern, matching the Spring Boot defaults that 2.8.14 effectively relied on. --- .../org/springdoc/webmvc/ui/SwaggerConfig.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/springdoc-openapi-starter-webmvc-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerConfig.java b/springdoc-openapi-starter-webmvc-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerConfig.java index 7c6a7221b..97e19bb9b 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerConfig.java +++ b/springdoc-openapi-starter-webmvc-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerConfig.java @@ -145,21 +145,24 @@ SwaggerIndexTransformer indexPageTransformer(SwaggerUiConfigProperties swaggerUi /** * Swagger web mvc configurer swagger web mvc configurer. * - * @param swaggerUiConfigProperties the swagger ui calculated config - * @param springWebProperties the spring web config - * @param springWebMvcProperties the spring mvc config - * @param swaggerIndexTransformer the swagger index transformer - * @param swaggerResourceResolver the swagger resource resolver - * @param swaggerWelcomeCommon the swagger welcome common + * @param swaggerUiConfigProperties the swagger ui calculated config + * @param springWebPropertiesProvider the spring web config provider + * @param springWebMvcPropertiesProvider the spring mvc config provider + * @param swaggerIndexTransformer the swagger index transformer + * @param swaggerResourceResolver the swagger resource resolver + * @param swaggerWelcomeCommon the swagger welcome common * @return the swagger web mvc configurer */ @Bean @ConditionalOnMissingBean @Lazy(false) SwaggerWebMvcConfigurer swaggerWebMvcConfigurer(SwaggerUiConfigProperties swaggerUiConfigProperties, - WebProperties springWebProperties, WebMvcProperties springWebMvcProperties, + ObjectProvider springWebPropertiesProvider, + ObjectProvider springWebMvcPropertiesProvider, SwaggerIndexTransformer swaggerIndexTransformer, SwaggerResourceResolver swaggerResourceResolver, SwaggerWelcomeCommon swaggerWelcomeCommon) { + WebProperties springWebProperties = springWebPropertiesProvider.getIfAvailable(WebProperties::new); + WebMvcProperties springWebMvcProperties = springWebMvcPropertiesProvider.getIfAvailable(WebMvcProperties::new); return new SwaggerWebMvcConfigurer(swaggerUiConfigProperties, springWebProperties, springWebMvcProperties, swaggerIndexTransformer, swaggerResourceResolver, swaggerWelcomeCommon); }