当该对象还有另一个剪切对象时,我从swaggerUi收到一个错误:
由以下原因引起:java.lang.NoSuchMethodError:io.swagger.models.properties.RefProperty。(Ljava / lang / String; Lio / swagger / models / refs / RefFormat;)V
Swagger版本为2.9.2(https://mvnrepository.com/artifact/io.springfox/springfox-swagger2/2.9.2,https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui/2.9.2),Java 11。
如果我将sender
字段的对象类型更改为String
,它可以正常工作,但是我希望它可以与自定义对象一起使用。
@Getter // lombok here
@Setter
@AllArgsConstructor
@XmlRootElement(name = "r")
@NoArgsConstructor
public class RDto {
private String id;
private String number;
private String status;
private String error;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@XmlRootElement(name="TDto")
public class MDto {
RDto sender; // If changed to String -> works fine
}
@Component
public class CamelConfig extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration().component("servlet") // configure we want to use servlet as the component for the rest DSL
.bindingMode(RestBindingMode.json_xml) // enable json/xml binding mode
.dataFormatProperty("prettyPrint", "true") // output using pretty print
.contextPath("/con/api/")
.apiContextPath("/api-doc") // enable swagger api
.apiProperty("api.version", "2.0.0")
.apiProperty("api.title", "title")
.apiProperty("api.description", "descr")
.apiProperty("api.contact.name", "Aaa")
.apiProperty("cors", "true"); // enable CORS
// error handling to return custom HTTP status codes for the various exceptions
onException(TestMessageException.class)
.handled(true)
// use HTTP status 400 when input data is invalid
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400))
.setBody(simple("Invalid input data"));
rest()
.description("rest service provider")
.consumes("application/xml").produces("application/xml")
.post("/send").type(MDto.class)
.bindingMode(RestBindingMode.json_xml).description("test")
.route().routeId("REST test").log("Message send: \n ${body}")
.to("bean:MService?method=test")
.endRest();
}
}
答案 0 :(得分:0)
我更改了出勤率(添加了排除项):
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
<artifactId>swagger-annotations</artifactId>
<groupId>io.swagger</groupId>
</exclusion>
<exclusion>
<artifactId>swagger-models</artifactId>
<groupId>io.swagger</groupId>
</exclusion>
</exclusions>
</dependency>
因为我也在用骆驼挥手
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
<version>3.0.0-M2</version>
<!--<version>2.23.2</version>-->
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-swagger-java</artifactId>
<version>3.0.0-M2</version>
<!-- use the same version as your Camel core version -->
</dependency>