我在使用基于XML的配置的现有Spring MVC项目中设置Springfox Swagger 2实现。
如何为下面的配置类声明XML配置?
package com.company.util;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.company.controllers.api"))
.paths(PathSelectors.regex("/api/.*"))
.build()
.apiInfo(custInfo());
}
public ApiInfo custInfo() {
ApiInfo apiInfo = new ApiInfo(
"Title",
"API Documentation",
"1.0",
"TOS",
new Contact("Contact", "https://www.company.com", "test@test.com"),
"license",
"https://www.license.com/"); //License URL
return apiInfo;
}
}