属性"Year"的冲突设置器定义(Springfox-Swagger2)

Raj*_*ami 1 java java-8 swagger-ui spring-boot swagger-2.0

我的问题与以下问题相同;

Jackson POJOPropertyBuilder在POJO中找到多个setter

但是,因为我使用"springfox-swagger2",我不使用SwaggerSpringMvcPlugin.

有没有办法解决这个问题?

Application.java

/* Makes this Application Run as Spring Boot Application */
@SpringBootApplication
/* Enables Swagger2API for documentation */
@EnableSwagger2
public class Application extends SpringBootServletInitializer { 

public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
    LogService.info(Application.class.getName(), "CustomerAPI Service Started");
}

@Bean
public Docket customerApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .groupName("Customer Application")
            .apiInfo(apiInfo())
            .select()
            .paths(myAppPaths())
            .build();
}

private ApiInfo apiInfo() {
    return new ApiInfoBuilder()
            .title("Customer API")
            .description("Some Description to Show")
            .termsOfServiceUrl(null)
            .contact("Test Test")
            .license("Apache License Version 2.0")
            .licenseUrl(
                    "https://github.com/springfox/springfox/blob/master/LICENSE")
            .version("2.0")
            .build();
}

@SuppressWarnings("unchecked")
private Predicate<String> myAppPaths() {
    return or(regex("/.*"));
}
Run Code Online (Sandbox Code Playgroud)

Raj*_*ami 5

解决了它.正如Springfox文档所说,Docket非常相似SwaggerSpringMvcPlugin.所以我们可以在下面做,这解决了这个问题.

@Bean
public Docket customerApi() {
return new Docket(DocumentationType.SWAGGER_2)
        .directModelSubstitute(XMLGregorianCalendar.class, String.class)
        .groupName("Customer Application")
        .apiInfo(apiInfo())
        .select()
        .paths(myAppPaths())
        .build();
}
Run Code Online (Sandbox Code Playgroud)

希望这将有助于将来的某些人.