Merge branch '1.5.x'
This commit is contained in:
@@ -45,14 +45,16 @@ dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter-jdbc")
|
||||
compile("org.springframework.boot:spring-boot-starter-security")
|
||||
compile("org.springframework.boot:spring-boot-starter-web")
|
||||
compile("com.h2database:h2")
|
||||
runtime("com.h2database:h2")
|
||||
|
||||
compileOnly('org.springframework.boot:spring-boot-configuration-processor')
|
||||
|
||||
testCompile("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
insecure configurations.runtime
|
||||
}
|
||||
|
||||
// Slightly odd requirement (package a jar file as an insecure app, exlcuding Spring Security)
|
||||
// Slightly odd requirement (package a jar file as an insecure app, excluding Spring Security)
|
||||
// just to demonstrate the "customConfiguration" feature of the Boot gradle plugin.
|
||||
springBoot {
|
||||
customConfiguration = "insecure"
|
||||
|
||||
@@ -38,7 +38,15 @@
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@@ -16,14 +16,16 @@
|
||||
|
||||
package sample.actuator;
|
||||
|
||||
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();
|
||||
|
||||
@@ -20,17 +20,25 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SampleActuatorApplication implements HealthIndicator {
|
||||
|
||||
@Override
|
||||
public Health health() {
|
||||
return Health.up().withDetail("hello", "world").build();
|
||||
}
|
||||
@EnableConfigurationProperties(ServiceProperties.class)
|
||||
public class SampleActuatorApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(SampleActuatorApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HealthIndicator helloHealthIndicator() {
|
||||
return new HealthIndicator() {
|
||||
@Override
|
||||
public Health health() {
|
||||
return Health.up().withDetail("hello", "world").build();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.Map;
|
||||
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Description;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -36,8 +35,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Description("A controller for handling requests for hello messages")
|
||||
public class SampleController {
|
||||
|
||||
@Autowired
|
||||
private HelloWorldService helloWorldService;
|
||||
private final HelloWorldService helloWorldService;
|
||||
|
||||
public SampleController(HelloWorldService helloWorldService) {
|
||||
this.helloWorldService = helloWorldService;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
@ResponseBody
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
package sample.actuator;
|
||||
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user