Spring Boot 3 和 OpenApi 3 (1.6.13) 不起作用。白标错误页面

Oct*_*via 2 spring-boot openapi springdoc java-17

我正在尝试使用 Spring Boot 3、Java 17、Open Api 3 查看 Swagger 页面。

我一定做错了什么,但是什么?是不是有什么不兼容的地方?

在 http://localhost:8080/v3/api-docs/ 或 http://localhost:8080/swagger-ui 我得到Whitelabel错误页面。

我正在从 Spring Boot 2.5 迁移,但为了确保我没有忘记删除导致此错误的某些内容,我从此处复制了一个教程https://www.techgeeknext.com/spring-boot/spring-boot- swagger3-example(我在这篇文章的末尾写了它)。

虽然运行了,但控制台中出现错误:

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)
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
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.jav