springboot项目中打包运行无法访问swagger
时间: 2023-04-04 11:00:23 浏览: 181
我可以为您提供一些可能的解决方案。首先,您可以检查您的Swagger配置是否正确,并确保Swagger UI的URL路径与您的应用程序的上下文路径匹配。另外,您可以尝试在pom.xml文件中添加以下依赖项:
```
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>3.25.</version>
</dependency>
```
如果问题仍然存在,您可以尝试在应用程序的启动类上添加@EnableSwagger2注释,并确保您的Swagger配置类正确地实现了SwaggerConfigurer接口。希望这些解决方案可以帮助您解决问题。
相关问题
springboot项目中打包完成后,运行此jar包无法访问swagger,正常运行则可以访问
可能是因为打包时没有将swagger相关的文件打包进去,可以尝试在pom.xml文件中添加以下配置:
```xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
```
这样打包时就会将所有资源文件都打包进去,包括swagger相关的文件。
springboot项目中安装Swagger要引入什么依赖
在SpringBoot项目中安装Swagger需要引入以下依赖:
```xml
<!--Swagger2-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-swagger2.version}</version>
</dependency>
<!--Swagger UI-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-swagger-ui.version}</version>
</dependency>
```
其中`${springfox-swagger2.version}`和`${springfox-swagger-ui.version}`需要根据实际情况进行替换,可以在Maven仓库中查找最新的版本号。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)