Polish samples

This commit is contained in:
Stephane Nicoll
2016-12-30 17:57:14 +01:00
parent a19a28062f
commit c903ff46a7
30 changed files with 149 additions and 105 deletions

View File

@@ -16,14 +16,16 @@
package sample.actuator.noweb;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class HelloWorldService {
@Autowired
private ServiceProperties configuration;
private final ServiceProperties configuration;
public HelloWorldService(ServiceProperties configuration) {
this.configuration = configuration;
}
public String getHelloMessage() {
return "Hello " + this.configuration.getName();

View File

@@ -18,8 +18,10 @@ package sample.actuator.noweb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@SpringBootApplication
@EnableConfigurationProperties(ServiceProperties.class)
public class SampleActuatorNoWebApplication {
public static void main(String[] args) throws Exception {

View File

@@ -17,12 +17,13 @@
package sample.actuator.noweb;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
@Component
public class ServiceProperties {
/**
* Name of the service.
*/
private String name = "World";
public String getName() {