diff --git a/powerjob-server/pom.xml b/powerjob-server/pom.xml index 80a62d2e..ad6e673e 100644 --- a/powerjob-server/pom.xml +++ b/powerjob-server/pom.xml @@ -214,6 +214,7 @@ + build-info repackage diff --git a/powerjob-server/src/main/java/com/github/kfcfans/powerjob/server/common/config/SwaggerConfig.java b/powerjob-server/src/main/java/com/github/kfcfans/powerjob/server/common/config/SwaggerConfig.java index 804e45ce..6334df98 100644 --- a/powerjob-server/src/main/java/com/github/kfcfans/powerjob/server/common/config/SwaggerConfig.java +++ b/powerjob-server/src/main/java/com/github/kfcfans/powerjob/server/common/config/SwaggerConfig.java @@ -1,5 +1,6 @@ package com.github.kfcfans.powerjob.server.common.config; +import org.springframework.boot.info.BuildProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; @@ -8,18 +9,24 @@ import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; +import javax.annotation.Resource; + import static springfox.documentation.builders.PathSelectors.any; /** * Swagger UI 配置 * * @author tjq + * @author Jiang Jining * @since 2020/3/29 */ @Configuration @EnableSwagger2 public class SwaggerConfig { - + + @Resource + private BuildProperties buildProperties; + @Bean public Docket createRestApi() { // apiInfo()用来创建该Api的基本信息(这些基本信息会展现在文档页面中 @@ -28,9 +35,9 @@ public class SwaggerConfig { .description("Distributed scheduling and computing framework.") .license("Apache Licence 2") .termsOfServiceUrl("https://github.com/KFCFans/PowerJob") - .version("3.3.3") + .version(buildProperties.getVersion()) .build(); - + return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo) // select()函数返回一个ApiSelectorBuilder实例 @@ -39,5 +46,5 @@ public class SwaggerConfig { .paths(any()) .build(); } - + }