Java 使用beanConfig启用Jersey 2.0的招摇过市功能
在Jersy2应用程序中,我有以下配置来设置swaggerJava 使用beanConfig启用Jersey 2.0的招摇过市功能,java,jersey,swagger,jersey-2.0,Java,Jersey,Swagger,Jersey 2.0,在Jersy2应用程序中,我有以下配置来设置swagger @ApplicationPath("/*") public class CreativeDeliveryServiceApplication extends ResourceConfig { /** * Registers the resources for the application and binds implementations to * interfaces for dependency injection. */
@ApplicationPath("/*")
public class CreativeDeliveryServiceApplication extends ResourceConfig {
/**
* Registers the resources for the application and binds implementations to
* interfaces for dependency injection.
*/
public CreativeDeliveryServiceApplication() {
register(MultiPartFeature.class);
.......
register(io.swagger.jaxrs.listing.ApiListingResource.class);
register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.0");
beanConfig.setSchemes(new String[]{"http"});
beanConfig.setHost("localhost:8080");
beanConfig.setBasePath("/api");
beanConfig.setResourcePackage("com.my.resources");
beanConfig.setScan(true);
packages(true, "com.my.resources");
}
}
我试图在localhost:8080/api/swagger.json上找到swagger.json,但没有找到404资源
我假设我应该遵循localhost:8080/{ApplicationPath}/{basePath}/swagger.json
因为我的应用程序路径是@ApplicationPath(“/*”),所以我将其省略为
localhost:8080/api/swagger.json
我怎样才能解决这个问题
Pom.xml
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.5.0</version>
</dependency>
昂首阔步
大摇大摆的运动衫2-jaxrs
1.5.0