BAEL-3499 Added files for article (#8498)
This commit is contained in:
parent
7a186e9bc8
commit
56f11da504
@ -7,10 +7,11 @@
|
|||||||
<name>spring-boot</name>
|
<name>spring-boot</name>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<description>This is simple boot application for Spring boot actuator test</description>
|
<description>This is simple boot application for Spring boot actuator test</description>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<artifactId>parent-boot-2</artifactId>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-2</relativePath>
|
<relativePath>../parent-boot-2</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
@ -198,6 +199,16 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<delimiters>
|
||||||
|
<delimiter>@</delimiter>
|
||||||
|
</delimiters>
|
||||||
|
<useDefaultDelimiters>false</useDefaultDelimiters>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
||||||
</build>
|
</build>
|
||||||
@ -251,6 +262,7 @@
|
|||||||
<graphql-java-tools.version>5.2.4</graphql-java-tools.version>
|
<graphql-java-tools.version>5.2.4</graphql-java-tools.version>
|
||||||
<guava.version>18.0</guava.version>
|
<guava.version>18.0</guava.version>
|
||||||
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
|
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
|
||||||
|
<resource.delimiter>@</resource.delimiter>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
2
spring-boot/src/main/resources/build.properties
Normal file
2
spring-boot/src/main/resources/build.properties
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
application-description=@project.description@
|
||||||
|
application-version=@project.version@
|
2
spring-boot/src/main/resources/build.yml
Normal file
2
spring-boot/src/main/resources/build.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
application-description: ^project.description^
|
||||||
|
application-version: ^project.version^
|
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user