在Debian上部署Swagger的过程可能因具体的应用和框架而异,但以下步骤提供了一般的指导:
pom.xml
文件中:<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
SwaggerConfig.java
,并使用@EnableSwagger2
注解来启用Swagger。import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
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.example.demo"))
.paths(PathSelectors.any())
.build();
}
}
scp
或rsync
命令将WAR文件传输到Debian服务器。http://<your-server-ip>:8080/swagger-ui.html
来访问。请注意,上述信息提供了一般的指导,具体的部署步骤可能会根据你使用的框架和工具有所不同。建议查阅相关框架的官方文档以获取更详细的部署指南。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:Swagger在Debian上如何配置