diff --git a/arex-schedule-web-api/pom.xml b/arex-schedule-web-api/pom.xml index dc949063..e660e965 100644 --- a/arex-schedule-web-api/pom.xml +++ b/arex-schedule-web-api/pom.xml @@ -129,11 +129,6 @@ aspectjweaver org.aspectj - - org.apache.maven - maven-model - 3.6.3 - 4.0.0 ${project.groupId}:${project.artifactId} @@ -185,6 +180,12 @@ 1.6.13 + + + src/main/resources + true + + war @@ -197,6 +198,12 @@ + + + src/main/resources + true + + maven-compiler-plugin diff --git a/arex-schedule-web-api/src/main/java/com/arextest/schedule/web/controller/CheckHealthController.java b/arex-schedule-web-api/src/main/java/com/arextest/schedule/web/controller/CheckHealthController.java index 5b8f6660..3359a564 100644 --- a/arex-schedule-web-api/src/main/java/com/arextest/schedule/web/controller/CheckHealthController.java +++ b/arex-schedule-web-api/src/main/java/com/arextest/schedule/web/controller/CheckHealthController.java @@ -2,10 +2,8 @@ import com.arextest.common.model.response.Response; import com.arextest.common.utils.ResponseUtils; -import java.io.FileReader; import lombok.extern.slf4j.Slf4j; -import org.apache.maven.model.Model; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -17,28 +15,12 @@ @RequestMapping("/vi/") @CrossOrigin(origins = "*", maxAge = 3600) public class CheckHealthController { - - private static Model POM_MODEL; - - static { - try { - POM_MODEL = new MavenXpp3Reader().read(new FileReader("pom.xml")); - } catch (Exception e) { - LOGGER.error("Read pom failed!", e); - } - } + @Value("${pom.version}") + private String VERSION; @GetMapping(value = "/health", produces = "application/json") @ResponseBody public Response checkHealth() { - return ResponseUtils.successResponse(getVersion()); - } - - private static String getVersion() { - if (POM_MODEL != null) { - return POM_MODEL.getVersion(); - } else { - return "error"; - } + return ResponseUtils.successResponse(VERSION); } } diff --git a/arex-schedule-web-api/src/main/resources/application.properties b/arex-schedule-web-api/src/main/resources/application.properties index 5a113304..a7928397 100644 --- a/arex-schedule-web-api/src/main/resources/application.properties +++ b/arex-schedule-web-api/src/main/resources/application.properties @@ -36,4 +36,5 @@ arex.schedule.monitor.secondToRefresh=5 arex.client.https.cert.disable=true arex.prometheus.port=20092 arex.app.auth.switch=false -ignore.time.precision.millis=2000 \ No newline at end of file +ignore.time.precision.millis=2000 +pom.version=${project.version} \ No newline at end of file