Skip to content

Commit 076657a

Browse files
committed
BAEL-579 Added actuator to Cloud Config Client.
1 parent f775bf9 commit 076657a

2 files changed

Lines changed: 82 additions & 76 deletions

File tree

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xmlns="http://maven.apache.org/POM/4.0.0"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
6-
7-
<parent>
8-
<groupId>com.baeldung.spring.cloud</groupId>
9-
<artifactId>spring-cloud-config</artifactId>
10-
<version>1.0-SNAPSHOT</version>
11-
</parent>
12-
<artifactId>client</artifactId>
13-
14-
<dependencies>
15-
<dependency>
16-
<groupId>org.springframework.cloud</groupId>
17-
<artifactId>spring-cloud-starter-config</artifactId>
18-
<version>${spring-cloud-starter-config.version}</version>
19-
</dependency>
20-
<dependency>
21-
<groupId>org.springframework.boot</groupId>
22-
<artifactId>spring-boot-starter-web</artifactId>
23-
<version>${org.springframework.boot.version}</version>
24-
</dependency>
25-
26-
<dependency>
27-
<groupId>org.springframework.boot</groupId>
28-
<artifactId>spring-boot-starter-test</artifactId>
29-
<version>${org.springframework.boot.version}</version>
30-
<scope>test</scope>
31-
</dependency>
32-
</dependencies>
33-
34-
<build>
35-
<plugins>
36-
<plugin>
37-
<groupId>org.springframework.boot</groupId>
38-
<artifactId>spring-boot-maven-plugin</artifactId>
39-
</plugin>
40-
</plugins>
41-
</build>
42-
43-
<properties>
44-
<spring-cloud-starter-config.version>1.2.2.RELEASE</spring-cloud-starter-config.version>
45-
<org.springframework.boot.version>1.4.2.RELEASE</org.springframework.boot.version>
46-
</properties>
47-
</project>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>com.baeldung.spring.cloud</groupId>
9+
<artifactId>spring-cloud-config</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
</parent>
12+
<artifactId>client</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.springframework.cloud</groupId>
17+
<artifactId>spring-cloud-starter-config</artifactId>
18+
<version>${spring-cloud-starter-config.version}</version>
19+
</dependency>
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter-web</artifactId>
23+
<version>${org.springframework.boot.version}</version>
24+
</dependency>
25+
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-test</artifactId>
29+
<version>${org.springframework.boot.version}</version>
30+
<scope>test</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-actuator</artifactId>
35+
</dependency>
36+
</dependencies>
37+
38+
<build>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-maven-plugin</artifactId>
43+
</plugin>
44+
</plugins>
45+
</build>
46+
47+
<properties>
48+
<spring-cloud-starter-config.version>1.2.2.RELEASE</spring-cloud-starter-config.version>
49+
<org.springframework.boot.version>1.4.2.RELEASE</org.springframework.boot.version>
50+
</properties>
51+
</project>
Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
package com.baeldung.spring.cloud.config.client;
2-
3-
import org.springframework.beans.factory.annotation.Value;
4-
import org.springframework.boot.SpringApplication;
5-
import org.springframework.boot.autoconfigure.SpringBootApplication;
6-
import org.springframework.http.MediaType;
7-
import org.springframework.web.bind.annotation.PathVariable;
8-
import org.springframework.web.bind.annotation.RequestMapping;
9-
import org.springframework.web.bind.annotation.RequestMethod;
10-
import org.springframework.web.bind.annotation.RestController;
11-
12-
@SpringBootApplication
13-
@RestController
14-
public class ConfigClient {
15-
@Value("${user.role}")
16-
private String role;
17-
18-
@Value("${user.password}")
19-
private String password;
20-
21-
public static void main(String[] args) {
22-
SpringApplication.run(ConfigClient.class, args);
23-
}
24-
25-
@RequestMapping(value = "/whoami/{username}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
26-
public String whoami(@PathVariable("username") String username) {
27-
return String.format("Hello %s! You are a(n) %s and your password is '%s'.\n", username, role, password);
28-
}
29-
}
1+
package com.baeldung.spring.cloud.config.client;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.cloud.context.config.annotation.RefreshScope;
7+
import org.springframework.http.MediaType;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.RequestMethod;
11+
import org.springframework.web.bind.annotation.RestController;
12+
13+
@SpringBootApplication
14+
@RestController
15+
@RefreshScope
16+
public class ConfigClient {
17+
@Value("${user.role}")
18+
private String role;
19+
20+
@Value("${user.password}")
21+
private String password;
22+
23+
public static void main(String[] args) {
24+
SpringApplication.run(ConfigClient.class, args);
25+
}
26+
27+
@RequestMapping(value = "/whoami/{username}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
28+
public String whoami(@PathVariable("username") String username) {
29+
return String.format("Hello %s! You are a(n) %s and your password is '%s'.\n", username, role, password);
30+
}
31+
}

0 commit comments

Comments
 (0)