Search code examples
spring-bootopenapijava-17springdoc

Spring Boot 3 and OpenApi 3 (1.6.13) doesn't work. Whitelabel Error Page


I am trying to get to see a Swagger page, using Spring Boot 3, Java 17, Open Api 3.

I must do something wrong, but what? Is there something that is not compatible?

On http://localhost:8080/v3/api-docs/ or http://localhost:8080/swagger-ui I getWhitelabel Error Page.

I am migrating from Spring Boot 2.5, but to be sure that I didn't forget to delete something resulting in this error, I copied a tutorial from here https://www.techgeeknext.com/spring-boot/spring-boot-swagger3-example (I wrote it in the end of this post).

Although it runs, in the console are the errors:

ERROR Class 'org.springframework.core.io.support.PathMatchingResourcePatternResolver' could not be processed by org.zeroturnaround.javarebel.integration.spring.core.cbp.PathMatchingResourcePatternResolverCBP@jdk.internal.loader.ClassLoaders$AppClassLoader@7a46a697: org.zeroturnaround.bundled.javassist.NotFoundException: retrieveMatchingFiles(..) is not found in org.springframework.core.io.support.PathMatchingResourcePatternResolver
    at org.zeroturnaround.bundled.javassist.CtClassType.getDeclaredMethod(SourceFile:1356)
    at org.zeroturnaround.javarebel.integration.spring.core.cbp.PathMatchingResourcePatternResolverCBP.registerScannedDirs(PathMatchingResourcePatternResolverCBP.java:255)
    at org.zeroturnaround.javarebel.integration.spring.core.cbp.PathMatchingResourcePatternResolverCBP.process(PathMatchingResourcePatternResolverCBP.java:41)
    at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:137)
    at org.zeroturnaround.javarebel.integration.support.CacheAwareJavassistClassBytecodeProcessor.process(SourceFile:34)
    at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:83)
    at com.zeroturnaround.javarebel.yg.a(SourceFile:413)
    at com.zeroturnaround.javarebel.yg.a(SourceFile:340)
    at com.zeroturnaround.javarebel.SDKIntegrationImpl.runBytecodeProcessors(SourceFile:44)
    at com.zeroturnaround.javarebel.vk.transform(SourceFile:140)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:43009)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at org.springframework.core.io.support.ResourceArrayPropertyEditor.<init>(ResourceArrayPropertyEditor.java:77)
    at org.springframework.beans.PropertyEditorRegistrySupport.createDefaultEditors(PropertyEditorRegistrySupport.java:218)
    at org.springframework.beans.PropertyEditorRegistrySupport.getDefaultEditor(PropertyEditorRegistrySupport.java:193)
    at org.springframework.boot.context.properties.bind.BindConverter$TypeConverterConverter.matches(BindConverter.java:209)
    at org.springframework.core.convert.support.GenericConversionService$ConvertersForPair.getConverter(GenericConversionService.java:663)
    at org.springframework.core.convert.support.GenericConversionService$Converters.getRegisteredConverter(GenericConversionService.java:560)
    at org.springframework.core.convert.support.GenericConversionService$Converters.find(GenericConversionService.java:544)
    at org.springframework.core.convert.support.GenericConversionService.getConverter(GenericConversionService.java:261)
    at org.springframework.core.convert.support.GenericConversionService.canConvert(GenericConversionService.java:146)
    at org.springframework.boot.context.properties.bind.BindConverter$TypeConverterConversionService.canConvert(BindConverter.java:167)
    at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:108)
    at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:100)
    at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:92)
    at org.springframework.boot.context.properties.bind.Binder.bindProperty(Binder.java:459)
    at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:403)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:343)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:332)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:262)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:223)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210)
    at org.springframework.boot.context.config.AnsiOutputApplicationListener.onApplicationEvent(AnsiOutputApplicationListener.java:43)
    at org.springframework.boot.context.config.AnsiOutputApplicationListener.onApplicationEvent(AnsiOutputApplicationListener.java:37)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:352)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291)
    at com.example.demo.DemoApplication.main(DemoApplication.java:14)
ERROR Class 'org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping' could not be processed by org.zeroturnaround.javarebel.integration.spring.cbp.AbstractDetectingUrlHandlerMappingCBP@jdk.internal.loader.ClassLoaders$AppClassLoader@7a46a697: org.zeroturnaround.bundled.javassist.CannotCompileException: [source error] no such class: HttpServletRequest
    at org.zeroturnaround.bundled.javassist.CtNewMethod.make(SourceFile:84)
    at org.zeroturnaround.bundled.javassist.CtNewMethod.make(SourceFile:50)
    at org.zeroturnaround.javarebel.integration.spring.cbp.AbstractDetectingUrlHandlerMappingCBP.process(AbstractDetectingUrlHandlerMappingCBP.java:31)
    at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:137)
    at org.zeroturnaround.javarebel.integration.support.CacheAwareJavassistClassBytecodeProcessor.process(SourceFile:34)
    at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:83)
    at com.zeroturnaround.javarebel.yg.a(SourceFile:413)
    at com.zeroturnaround.javarebel.yg.a(SourceFile:340)
    at com.zeroturnaround.javarebel.SDKIntegrationImpl.runBytecodeProcessors(SourceFile:44)
    at com.zeroturnaround.javarebel.vk.transform(SourceFile:140)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:43009)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:467)
    at com.zeroturnaround.javarebel.vs.a(SourceFile:139)
    at com.zeroturnaround.javarebel.vs.a(SourceFile:594)
    at com.zeroturnaround.javarebel.vk.transform(SourceFile:156)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:43009)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402)
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504)
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:465)
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:360)
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:374)
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:374)
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:417)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$1(AbstractAutowireCapableBeanFactory.java:749)
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1740)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:748)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:681)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:652)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1632)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:559)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:531)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:250)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:243)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:233)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:181)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:156)
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:183)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:409)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:283)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:344)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:115)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:745)
    at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:565)
    at org.springframework.context.support.AbstractApplicationContext.jrLockAndRefresh(AbstractApplicationContext.java:41002)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:42008)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291)
    at com.example.demo.DemoApplication.main(DemoApplication.java:14)
Caused by: compile error: no such class: HttpServletRequest
    at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.searchImports(SourceFile:479)
    at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupClass(SourceFile:422)
    at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupClassByJvmName(SourceFile:329)
    at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupClass(SourceFile:346)
    at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupClass(SourceFile:333)
    at org.zeroturnaround.bundled.javassist.compiler.MemberCodeGen.makeParamList(SourceFile:1167)
    at org.zeroturnaround.bundled.javassist.compiler.Javac.compileMethod(SourceFile:153)
    at org.zeroturnaround.bundled.javassist.compiler.Javac.compile(SourceFile:102)
    at org.zeroturnaround.bundled.javassist.CtNewMethod.make(SourceFile:79)
    ... 71 more
ERROR Class 'org.apache.tomcat.util.buf.MessageBytes' could not be processed by org.zeroturnaround.javarebel.integration.catalina.cbp.MessageBytesCBP@jdk.internal.loader.ClassLoaders$AppClassLoader@7a46a697: org.zeroturnaround.bundled.javassist.CannotCompileException: [source error] no such field: hasStrValue
    at org.zeroturnaround.bundled.javassist.CtNewMethod.make(SourceFile:84)
    at org.zeroturnaround.bundled.javassist.CtNewMethod.make(SourceFile:50)
    at org.zeroturnaround.javarebel.integration.catalina.cbp.MessageBytesCBP.process(MessageBytesCBP.java:27)
    at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:137)
    at org.zeroturnaround.javarebel.integration.support.CacheAwareJavassistClassBytecodeProcessor.process(SourceFile:34)
    at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:83)
    at com.zeroturnaround.javarebel.yg.a(SourceFile:413)
    at com.zeroturnaround.javarebel.yg.a(SourceFile:340)
    at com.zeroturnaround.javarebel.SDKIntegrationImpl.runBytecodeProcessors(SourceFile:44)
    at com.zeroturnaround.javarebel.vk.transform(SourceFile:140)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:43009)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at org.apache.coyote.Request.<init>(Request.java:98)
    at org.apache.coyote.AbstractProcessor.<init>(AbstractProcessor.java:81)
    at org.apache.coyote.http11.Http11Processor.<init>(Http11Processor.java:156)
    at org.apache.coyote.http11.AbstractHttp11Protocol.createProcessor(AbstractHttp11Protocol.java:703)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:850)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1739)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: compile error: no such field: hasStrValue
    at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupField(SourceFile:321)
    at org.zeroturnaround.bundled.javassist.compiler.MemberResolver.lookupFieldByJvmName(SourceFile:307)
    at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.fieldAccess(SourceFile:904)
    at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atFieldAssign(SourceFile:296)
    at org.zeroturnaround.bundled.javassist.compiler.JvstTypeChecker.atFieldAssign(SourceFile:95)
    at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atAssignExpr(SourceFile:255)
    at org.zeroturnaround.bundled.javassist.compiler.ast.AssignExpr.accept(SourceFile:43)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.doTypeCheck(SourceFile:266)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:362)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:53)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:383)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:53)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atIfStmnt(SourceFile:430)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:387)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:53)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:383)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:53)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atMethodBody(SourceFile:321)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atMethodDecl(SourceFile:303)
    at org.zeroturnaround.bundled.javassist.compiler.ast.MethodDecl.accept(SourceFile:47)
    at org.zeroturnaround.bundled.javassist.compiler.Javac.compileMethod(SourceFile:175)
    at org.zeroturnaround.bundled.javassist.compiler.Javac.compile(SourceFile:102)
    at org.zeroturnaround.bundled.javassist.CtNewMethod.make(SourceFile:79)
    ... 28 more
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
            <version>1.6.13</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .components(new Components())
                .info(new Info().title("Test")
                        .description("Test Description")
                        .version("1.0.0"));
    }

}

@RequestMapping("/api")
@RestController
public class Swagger3RestController {

    List<User> users = new ArrayList<User>();
    {
        users.add(new User(1,"TechGeekNext-User1", "ADMIN", "[email protected]"));
        users.add(new User(2,"TechGeekNext-User2", "SUPERVISOR", "[email protected]"));
        users.add(new User(3,"TechGeekNext-User3", "USER", "[email protected]"));
        users.add(new User(4,"TechGeekNext-User4", "USER", "[email protected]"));
    }


    @RequestMapping(value = "/getUsers", method = RequestMethod.GET, produces = "application/json")
    public List<User> getUsers() {
        return users;
    }

    @RequestMapping(value = "/getUser/{id}", method = RequestMethod.GET, produces = "application/json")
    public User getUserById(@PathVariable(value = "id") int id) {
        return users.stream().filter(x -> x.getId()==(id)).collect(Collectors.toList()).get(0);
    }

    @RequestMapping(value = "/getUser/role/{role}", method = RequestMethod.GET, produces = "application/json")
    public List<User> getUserByRole(@PathVariable(value = "role") String role) {
        return users.stream().filter(x -> x.getRole().equalsIgnoreCase(role))
                .collect(Collectors.toList());
    }

}

public class User {

    private int id;

    private String name;

    private String role;

    private String email;

    public User(int id, String name, String role, String email) {
        this.id = id;
        this.name = name;
        this.role = role;
        this.email = email;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", role='" + role + '\'' +
                ", email='" + email + '\'' +
                '}';
    }
}

Solution

  • I have encountered the same problem, finally found the dependency is different for Spring Boot 3.

    Try this instead of "springdoc-openapi-ui":

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

    source: https://springdoc.org/v2/