Polish samples
This commit is contained in:
@@ -17,11 +17,9 @@
|
||||
package sample.metrics.redis;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
|
||||
public class HelloWorldService {
|
||||
public class HelloWorldProperties {
|
||||
|
||||
private String name = "World";
|
||||
|
||||
@@ -33,8 +31,4 @@ public class HelloWorldService {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getHelloMessage() {
|
||||
return "Hello " + this.name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,14 +31,18 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Description("A controller for handling requests for hello messages")
|
||||
public class SampleController {
|
||||
|
||||
private final HelloWorldProperties helloWorldProperties;
|
||||
|
||||
@Autowired
|
||||
private HelloWorldService helloWorldService;
|
||||
public SampleController(HelloWorldProperties helloWorldProperties) {
|
||||
this.helloWorldProperties = helloWorldProperties;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
@ResponseBody
|
||||
public Map<String, String> hello() {
|
||||
return Collections.singletonMap("message",
|
||||
this.helloWorldService.getHelloMessage());
|
||||
return Collections.singletonMap("message", "Hello " +
|
||||
this.helloWorldProperties.getName());
|
||||
}
|
||||
|
||||
protected static class Message {
|
||||
|
||||
@@ -24,11 +24,13 @@ import org.springframework.boot.actuate.metrics.export.MetricExportProperties;
|
||||
import org.springframework.boot.actuate.metrics.jmx.JmxMetricWriter;
|
||||
import org.springframework.boot.actuate.metrics.repository.redis.RedisMetricRepository;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.jmx.export.MBeanExporter;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(HelloWorldProperties.class)
|
||||
public class SampleRedisExportApplication {
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user