在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
來訪問。請注意,上述信息提供了一般的指導,具體的部署步驟可能會根據你使用的框架和工具有所不同。建議查閱相關框架的官方文檔以獲取更詳細的部署指南。