java - 在Spring Data Rest中,使用profile的Swagger2配置问题

标签 java swagger spring-data-rest

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>3.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>3.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-data-rest</artifactId>
            <version>3.0.0-SNAPSHOT</version>
        </dependency>
@Profile({"dev-test", "local-test"})
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfig {

    @Bean
    public Docket documentation() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(s -> s.matches("/_api/.*"))
                .build();
    }
}

配置文件不是local-testdev-test时,会发生此错误。

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 4 of constructor in springfox.documentation.spring.data.rest.EntityServicesProvider required a bean of type 'com.fasterxml.classmate.TypeResolver' that could not be found.


Action:

Consider defining a bean of type 'com.fasterxml.classmate.TypeResolver' in your configuration.

嗨,我正在使用 Swagger3.0 和 Spring Data Rest。

这是我引用的链接。 https://stackoverflow.com/a/46458135/10345277

我正在做的是尝试通过配置文件打开或关闭 Swagger。

但是,与上面的链接不同,我使用 SDR 并且 springfox.documentation.spring.data.rest 抛出错误。

有解决办法吗?

最佳答案

就我而言 - 使用 io.springfox:springfox-swagger2:2.9.2 和 io.springfox:springfox-swagger-ui:2.9.2 - 触发此错误 war 是因为我忘记将 @EnableSwagger2 添加到我的 @Configuration 类

关于java - 在Spring Data Rest中,使用profile的Swagger2配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56288661/

相关文章:

odata - 什么是 Swagger,它与 OData 有关系吗?

java - 扫描另一个包中的存储库

java - Spring Data REST - 对数据库的前 10 次调用非常慢

java - 阿耳忒弥斯休息界面

javascript - Angular 版本 4 http 将数字作为字符串发送

java - 一个小程序让Windows 7彻底死机

java - Springfox 从 2.9.2 更新到 2.10.4 后错误 "Unable to infer base url. ..."

rest - 使用 Spring HATEOAS 将枚举作为 REST API 公开的正确方法是什么(通过 Spring Data REST)

java - 使用 jelastic 托管 Java Web 服务

Java 8 ArrayList 相等性