diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml
index 2152a0a00d..b8ebd27e13 100644
--- a/spring-boot/pom.xml
+++ b/spring-boot/pom.xml
@@ -7,16 +7,17 @@
spring-boot
war
This is simple boot application for Spring boot actuator test
+ 0.0.1-SNAPSHOT
- com.baeldung
parent-boot-2
+ com.baeldung
0.0.1-SNAPSHOT
../parent-boot-2
-
+
org.junit.jupiter
@@ -198,6 +199,16 @@
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+
+ @
+
+ false
+
+
@@ -251,6 +262,7 @@
5.2.4
18.0
2.2.4
+ @
diff --git a/spring-boot/src/main/java/com/baeldung/buildproperties/Application.java b/spring-boot/src/main/java/com/baeldung/buildproperties/Application.java
new file mode 100644
index 0000000000..405cec3eac
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/buildproperties/Application.java
@@ -0,0 +1,18 @@
+package com.baeldung.buildproperties;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.PropertySource;
+
+@SpringBootApplication
+@ComponentScan(basePackages = "com.baeldung.buildproperties")
+@PropertySource("classpath:build.properties")
+//@PropertySource("classpath:build.yml")
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+}
diff --git a/spring-boot/src/main/java/com/baeldung/buildproperties/BuildInfoService.java b/spring-boot/src/main/java/com/baeldung/buildproperties/BuildInfoService.java
new file mode 100644
index 0000000000..2a0d27188e
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/buildproperties/BuildInfoService.java
@@ -0,0 +1,21 @@
+package com.baeldung.buildproperties;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Service
+public class BuildInfoService {
+ @Value("${application-description}")
+ private String applicationDescription;
+
+ @Value("${application-version}")
+ private String applicationVersion;
+
+ public String getApplicationDescription() {
+ return applicationDescription;
+ }
+
+ public String getApplicationVersion() {
+ return applicationVersion;
+ }
+}
diff --git a/spring-boot/src/main/resources/build.properties b/spring-boot/src/main/resources/build.properties
new file mode 100644
index 0000000000..1612b8086d
--- /dev/null
+++ b/spring-boot/src/main/resources/build.properties
@@ -0,0 +1,2 @@
+application-description=@project.description@
+application-version=@project.version@
\ No newline at end of file
diff --git a/spring-boot/src/main/resources/build.yml b/spring-boot/src/main/resources/build.yml
new file mode 100644
index 0000000000..528d2e3440
--- /dev/null
+++ b/spring-boot/src/main/resources/build.yml
@@ -0,0 +1,2 @@
+application-description: ^project.description^
+application-version: ^project.version^
\ No newline at end of file
diff --git a/spring-boot/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java
new file mode 100644
index 0000000000..cb056fe56d
--- /dev/null
+++ b/spring-boot/src/test/java/com/baeldung/buildproperties/BuildInfoServiceIntegrationTest.java
@@ -0,0 +1,24 @@
+package com.baeldung.buildproperties;
+
+import static org.junit.Assert.assertThat;
+
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+class BuildInfoServiceIntegrationTest {
+
+ @Autowired
+ private BuildInfoService service;
+
+ @Test
+ void whenGetApplicationDescription_thenSuccess() {
+ assertThat(service.getApplicationDescription(), Matchers.is("This is simple boot application for Spring boot actuator test"));
+ assertThat(service.getApplicationVersion(), Matchers.is("0.0.1-SNAPSHOT"));
+ }
+}