Swagger提示版本和POM中版本通过配置保持一致

This commit is contained in:
zengqiao
2022-01-17 13:17:07 +08:00
parent d6181522c0
commit f6ba8bc95e
5 changed files with 13 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ server:
spring:
application:
name: kafkamanager
version: @project.version@
profiles:
active: dev
datasource:

View File

@@ -15,6 +15,7 @@ server:
spring:
application:
name: kafkamanager
version: @project.version@
profiles:
active: dev
datasource:

View File

@@ -18,6 +18,9 @@ public class ConfigUtils {
@Value(value = "${custom.idc:cn}")
private String idc;
@Value(value = "${spring.profiles.active}")
@Value(value = "${spring.profiles.active:dev}")
private String kafkaManagerEnv;
@Value(value = "${spring.application.version:unknown}")
private String applicationVersion;
}

View File

@@ -1,5 +1,7 @@
package com.xiaojukeji.kafka.manager.web.config;
import com.xiaojukeji.kafka.manager.service.utils.ConfigUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;
@@ -20,6 +22,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableWebMvc
@EnableSwagger2
public class SwaggerConfig implements WebMvcConfigurer {
@Autowired
private ConfigUtils configUtils;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
@@ -41,7 +46,7 @@ public class SwaggerConfig implements WebMvcConfigurer {
return new ApiInfoBuilder()
.title("LogiKM接口文档")
.description("欢迎使用滴滴LogiKM")
.version("2.5.0")
.version(configUtils.getApplicationVersion())
.build();
}

View File

@@ -9,6 +9,7 @@ server:
spring:
application:
name: kafkamanager
version: @project.version@
profiles:
active: dev
datasource: