How I run swagger on Spring Boot version 3.2.1

I’m trying to run swagger ui on spring boot v 3.2.1 but I’m unable to view on the web ui – http://localhost:8080/webjars/swagger-ui/index.html#/

This is my build.gradle

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.2.1'
    id 'io.spring.dependency-management' version '1.1.4'
}

group = 'com.naman.jain'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

// Disables the default jar task, preventing the creation of a JAR file during the build process.
// This is useful in scenarios where the project does not require a JAR file,
// such as when only a WAR file is needed or in specific modules of a multi-module project.
jar {
    enabled = false
}


dependencies {
    implementation project(':api')
    implementation project(':util')

    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'

    // https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-starter-webflux-ui
//  implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webflux-ui', version: '2.6.0'
    implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.5.0'

    // To avoid the following error message on Apple silicon (for details, see https://github.com/netty/netty/issues/11693):
    // Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.
    implementation group: 'io.netty', name: 'netty-resolver-dns-native-macos', classifier: 'osx-aarch_64'

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

The logs from the service container:

product-composite-1  | 
product-composite-1  |   .   ____          _            __ _ _
product-composite-1  |  /\ / ___'_ __ _ _(_)_ __  __ _    
product-composite-1  | ( ( )___ | '_ | '_| | '_ / _` |    
product-composite-1  |  \/  ___)| |_)| | | | | || (_| |  ) ) ) )
product-composite-1  |   '  |____| .__|_| |_|_| |___, | / / / /
product-composite-1  |  =========|_|==============|___/=/_/_/_/
product-composite-1  |  :: Spring Boot ::                (v3.2.1)
product-composite-1  | 
product-composite-1  | 2024-09-03T21:23:55.107Z  INFO 1 --- [           main] j.c.p.ProductCompositeServiceApplication : Starting ProductCompositeServiceApplication v0.0.1-SNAPSHOT using Java 17.0.12 with PID 1 (/application/BOOT-INF/classes started by root in /application)
product-composite-1  | 2024-09-03T21:23:55.124Z DEBUG 1 --- [           main] j.c.p.ProductCompositeServiceApplication : Running with Spring Boot v3.2.1, Spring v6.1.2
product-composite-1  | 2024-09-03T21:23:55.126Z  INFO 1 --- [           main] j.c.p.ProductCompositeServiceApplication : The following 1 profile is active: "docker"
product-composite-1  | 2024-09-03T21:24:01.708Z  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
product-composite-1  | 2024-09-03T21:24:01.806Z  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
product-composite-1  | 2024-09-03T21:24:01.807Z  INFO 1 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.17]
product-composite-1  | 2024-09-03T21:24:02.169Z  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
product-composite-1  | 2024-09-03T21:24:02.185Z  INFO 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 6451 ms
product-composite-1  | 2024-09-03T21:24:06.165Z  INFO 1 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
product-composite-1  | 2024-09-03T21:24:06.647Z  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path ''
product-composite-1  | 2024-09-03T21:24:06.705Z  INFO 1 --- [           main] j.c.p.ProductCompositeServiceApplication : Started ProductCompositeServiceApplication in 13.851 seconds (process running for 15.837)

On trying to open the swagger page, I’m facing the resource not found error on webpage with no logs on docker.
(No static resource swagger-ui/index.html.)

Update 1: Not working with following config as well

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.3.3'
    id 'io.spring.dependency-management' version '1.1.6'
}

group = 'com.naman.jain'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

// Disables the default jar task, preventing the creation of a JAR file during the build process.
// This is useful in scenarios where the project does not require a JAR file,
// such as when only a WAR file is needed or in specific modules of a multi-module project.
jar {
    enabled = false
}


dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'

    // https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-starter-webflux-ui
    implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.6.0'

    implementation project(':api')
    implementation project(':util')

    // To avoid the following error message on Apple silicon (for details, see https://github.com/netty/netty/issues/11693):
    // Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.
    implementation group: 'io.netty', name: 'netty-resolver-dns-native-macos', classifier: 'osx-aarch_64'

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

3

This is an example from the book. I had the same error)

You should change versions.

In the “api” module, I have:

implementation 'org.springdoc:springdoc-openapi-starter-common:2.6.0'

And in this module:

implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.6.0'

PS: I also changed the Spring Boot version to 3.3.3. It works for me.

2

Agree with @kozlovskiy-kirill, you can either bump both spring-boot + springdoc to latest 3.3.x & 2.6.0 OR bump to 3.2.4 that matches springdoc 2.5.0.

See https://github.com/springdoc/springdoc-openapi/releases for info on what version each springdoc release is set up for.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật