行业资讯 2025年08月6日
0 收藏 0 点赞 701 浏览 1472 个字
摘要 :

在使用IDEA+SpringBoot集成Swagger2时发现SpringBoot启动正常,没有报错,但当使用浏览器防止http://localhost:8080/swagger-ui.html地址时浏览器提示如下: Unable to ……

在使用IDEA+SpringBoot集成Swagger2时发现SpringBoot启动正常,没有报错,但当使用浏览器防止http://localhost:8080/swagger-ui.html地址时浏览器提示如下:
SpringBoot集成Swagger2报错Unable to infer base url. This is common…API Gateway

Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is http://example.org/api/. Please enter the location manually:http://localhost:8080/swagger-ui.html

然后发现IDEA控制台也会不停的报错如下:

Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonIncludeProperties
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_202]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_202]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_202]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_202]
… 61 common frames omitted

从报错情况可以看出是因为少jackson的相关jar包导致的(而缺少的原因也可能是SpringBoot版本和Swagger版本不匹配原因导致的,不过在此我们暂不考虑)。

解决办法:

pom.xml导入jackson相关的依赖,具体如下:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.11.2</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.11.2</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.11.2</version>
</dependency>

这里我使用2.11.2版本是因为SpringBoot好像也内置了相关的jar,低版本好像会有冲突。导入成功后我们重启SpringBoot再次访问,发现成功了:
SpringBoot集成Swagger2报错Unable to infer base url. This is common…API Gateway

微信扫一扫

支付宝扫一扫

版权: 转载请注明出处:https://www.zuozi.net/8049.html

管理员

相关推荐
2025-08-06

文章目录 一、Reader 接口概述 1.1 什么是 Reader 接口? 1.2 Reader 与 InputStream 的区别 1.3 …

988
2025-08-06

文章目录 一、事件溯源 (一)核心概念 (二)Kafka与Golang的优势 (三)完整代码实现 二、命令…

465
2025-08-06

文章目录 一、证明GC期间执行native函数的线程仍在运行 二、native线程操作Java对象的影响及处理方…

348
2025-08-06

文章目录 一、事务基础概念 二、MyBatis事务管理机制 (一)JDBC原生事务管理(JdbcTransaction)…

456
2025-08-06

文章目录 一、SnowFlake算法核心原理 二、SnowFlake算法工作流程详解 三、SnowFlake算法的Java代码…

517
2025-08-06

文章目录 一、本地Jar包的加载操作 二、本地Class的加载方法 三、远程Jar包的加载方式 你知道Groo…

832
发表评论
暂无评论

还没有评论呢,快来抢沙发~

助力内容变现

将您的收入提升到一个新的水平

点击联系客服

在线时间:08:00-23:00

客服QQ

122325244

客服电话

400-888-8888

客服邮箱

122325244@qq.com

扫描二维码

关注微信客服号