只是学习如何maven和spring Boot 工作,所以我一直在做一些简单的项目来练习。但是我遇到了一个问题,我的swagger-ui.html给我一个404错误没有找到。
我在pom.xml中为swagger-ui添加的内容。
`
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.0-M4</version>
</dependency>
我的整个项目代码是可用的[here](https://github.com/aakhoja/restful-web-services) 做一点谷歌搜索,我发现一些解决方案,还没有帮助我与我的项目。 我添加的内容: @启用Mvc @Configuration 在我的主控制器类中。添加这两个注解后,我的错误显示了一个不同的错误。粘贴如下:
Error creating bean with name 'org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0;我还尝试添加了许多其他依赖项,如
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
``
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
`
任何帮助将不胜感激!
3条答案
按热度按时间d6kp6zgx1#
用户界面需要springboot 3.0以上版本
8i9zcol22#
是jdk版本17吗?因为我看到它是在
pom.xml
文件中配置的。ryoqjall3#
@丁浩是正确的,因为你需要springboot 3.0+来运行webmvc-ui。我正在寻找方法来启用swagger与我目前的版本的Spring(2.7.5),但后来我决定升级springboot到3.0。
下面的代码将我的springboot从2.7.5升级到了springboot 3.0.0-M4。在用maven重新编译之后,我可以成功地访问localhost:8080/swagger-ui.html。
我更新的代码项目可以在here中找到