@Bean
public Server rsServer2() {
JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
endpoint.setProvider(new JacksonJsonProvider());
endpoint.setBus(cxf());
endpoint.setAddress("/rservice2");
endpoint.setServiceBeans(Arrays.<Object>asList(someService3));
endpoint.setFeatures(Arrays.asList(swagger2Feature2()));
return endpoint.create();
}
@Bean
public Server rsServer() {
JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
endpoint.setProvider(new JacksonJsonProvider());
endpoint.setBus(cxf());
endpoint.setAddress("/rservice");
endpoint.setServiceBeans(Arrays.<Object>asList(someService2));
endpoint.setFeatures(Arrays.asList(swagger2Feature()));
return endpoint.create();
}
@Bean("swagger2Feature")
Swagger2Feature swagger2Feature() {
System.out.println("Swagger2Feature Called");
Swagger2Feature swagger2Feature = new Swagger2Feature();
swagger2Feature.setResourcePackage("com.service2");
swagger2Feature.setPrettyPrint(true);
return swagger2Feature;
}
@Bean("swagger2Feature2")
Swagger2Feature swagger2Feature2() {
System.out.println("Swagger2Feature2 Called");
Swagger2Feature swagger2Feature2 = new Swagger2Feature();
swagger2Feature2.setResourcePackage("com.service3");
swagger2Feature2.setPrettyPrint(true);
return swagger2Feature2;
}
//
在浏览器中点击/ basepath / rservice / services时。下面列出了api。
/basepath/rservice2/api-docs?url=/basepath/rservice2/swagger.json
/basepath/rservice/api-docs?url=/basepath/rservice2/swagger.json
两个链接都提供仅在列出的服务 swagger2Feature.setResourcePackage(“ com.service2”)。
所需结果:两个链接都应在相应的swagger2Feature.setResourcePackage中列出各自的api。