Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Springdoc with Spring Boot 3 Native

I am trying to use Springdoc v2 with Spring Boot 3. It works fine when running it with the JVM, but not when running the native binary.

The Spring boot project is created like this: https://start.spring.io/#!type=maven-project&language=java&platformVersion=3.0.0&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=native,web,lombok

I've added the Springdoc dependency:

<dependency>
   <groupId>org.springdoc</groupId>
   <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
   <version>2.0.0</version>
</dependency>

Starting the jar file, I can browse http://localhost:8080/swagger-ui/index.html, but when I run the native binary, I get a 404.

According to the documentation, it seems to support it out of the box: https://springdoc.org/v2/

like image 278
Sim Avatar asked Oct 24 '25 08:10

Sim


1 Answers

You are using correct dependency

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.0.0</version>
</dependency>

but missing the property below

springdoc.enable-native-support=true
springdoc.swagger-ui.path=/swagger-ui

here the working example. After build you can see swagger ui working at http://localhost:8080/swagger-ui which will redirect to http://localhost:8080/swagger-ui/4.15.5/index.html

like image 179
ozkanpakdil Avatar answered Oct 25 '25 21:10

ozkanpakdil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!