Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring Boot:Swagger UI白标签错误_Java_Spring Boot_Swagger_Swagger Ui - Fatal编程技术网

Java Spring Boot:Swagger UI白标签错误

Java Spring Boot:Swagger UI白标签错误,java,spring-boot,swagger,swagger-ui,Java,Spring Boot,Swagger,Swagger Ui,当我运行下面的程序时,当我访问localhost:8080/swagger-ui.html时,我得到一个白标签错误。我认为所有必需的依赖项(springfox-swagger 2、springfox swagger ui)都已导入并正确配置了swagger。请告诉我怎么了 招摇过市配置 @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket swagConfig() {

当我运行下面的程序时,当我访问localhost:8080/swagger-ui.html时,我得到一个白标签错误。我认为所有必需的依赖项(springfox-swagger 2、springfox swagger ui)都已导入并正确配置了swagger。请告诉我怎么了

招摇过市配置

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket swagConfig() {
        return new Docket(DocumentationType.SWAGGER_2).select()
                .apis(RequestHandlerSelectors.basePackage("com.learn.microservices")).build();
    }
}
pom.xml

<?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>2.4.5</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.doit</groupId>
    <artifactId>microservices</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>microservices</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>3.0.0</version>
        </dependency>

    </dependencies>

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

</project>

4.0.0
org.springframework.boot
spring启动程序父级
2.4.5
com.doit
微服务
0.0.1-快照
微服务
SpringBoot的演示项目
1.8
org.springframework.boot
弹簧靴起动器执行器
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧靴开发工具
运行时
真的
org.springframework.boot
弹簧起动试验
测试
伊奥·斯普林福克斯
springfox-Swagger 2
3.0.0
伊奥·斯普林福克斯
springfox招摇过市用户界面
3.0.0
org.springframework.boot
springbootmaven插件
尝试添加路径,您的代码将丢失此部分。 参考:

public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any()).build();
    }