小编Pie*_*rot的帖子

试图访问 swagger-ui 或 api/api-docs 但出现 404 错误

这是我的第一篇文章,所以请随时留下一些反馈,或者如果我做错了什么:)

我正在使用 spring-boot 和 resteasy :

<!-- Spring Boot -->
<dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-dependencies</artifactId>
 <version>2.1.0.RELEASE</version>
 <type>pom</type>
 <scope>import</scope>
</dependency>
<dependency>
  <groupId>com.paypal.springboot</groupId>
  <artifactId>resteasy-spring-boot-starter</artifactId>
  <version>2.3.4-RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用 Swagger 来查看我的端点,所以我添加了这个依赖项:

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

此依赖项已加载到我的存储库中,一切看起来都不错。


我添加了这个类来制作最简单的配置类:

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
}
Run Code Online (Sandbox Code Playgroud)

当我在调试模式中启动应用程序时,我输入了这个以前的 Bean。一切看起来都很好。


当我启动 Spring 应用程序时:

@SpringBootApplication
@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class,RabbitAutoConfiguration.class})
public class SituationServicesApplication implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(SituationServicesApplication.class, args);
    }
    @Override …
Run Code Online (Sandbox Code Playgroud)

java swagger-ui spring-boot swagger-2.0 springfox

6
推荐指数
1
解决办法
5593
查看次数

标签 统计

java ×1

spring-boot ×1

springfox ×1

swagger-2.0 ×1

swagger-ui ×1