冲突 Setter 定义 属性 "Year" (Springfox-Swagger2)
Conflict Setter Definition For Property "Year" (Springfox-Swagger2)
我的问题和下面的问题一样;
但是,当我使用 "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("/.*"));
}
解决了。正如 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();
}
希望这对以后的人有所帮助。
我的问题和下面的问题一样;
但是,当我使用 "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("/.*"));
}
解决了。正如 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();
}
希望这对以后的人有所帮助。