Skip to content

Commit 4604bb7

Browse files
committed
Merge branch '1.5.x'
2 parents 22a384a + c903ff4 commit 4604bb7

File tree

48 files changed

+180
-193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+180
-193
lines changed

spring-boot-samples/spring-boot-sample-actuator-noweb/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
<groupId>org.springframework.boot</groupId>
2424
<artifactId>spring-boot-starter-actuator</artifactId>
2525
</dependency>
26+
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-configuration-processor</artifactId>
30+
<optional>true</optional>
31+
</dependency>
32+
2633
<dependency>
2734
<groupId>org.springframework.boot</groupId>
2835
<artifactId>spring-boot-starter-test</artifactId>

spring-boot-samples/spring-boot-sample-actuator-noweb/src/main/java/sample/actuator/noweb/HelloWorldService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616

1717
package sample.actuator.noweb;
1818

19-
import org.springframework.beans.factory.annotation.Autowired;
2019
import org.springframework.stereotype.Component;
2120

2221
@Component
2322
public class HelloWorldService {
2423

25-
@Autowired
26-
private ServiceProperties configuration;
24+
private final ServiceProperties configuration;
25+
26+
public HelloWorldService(ServiceProperties configuration) {
27+
this.configuration = configuration;
28+
}
2729

2830
public String getHelloMessage() {
2931
return "Hello " + this.configuration.getName();

spring-boot-samples/spring-boot-sample-actuator-noweb/src/main/java/sample/actuator/noweb/SampleActuatorNoWebApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
import org.springframework.boot.SpringApplication;
2020
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2122

2223
@SpringBootApplication
24+
@EnableConfigurationProperties(ServiceProperties.class)
2325
public class SampleActuatorNoWebApplication {
2426

2527
public static void main(String[] args) throws Exception {

spring-boot-samples/spring-boot-sample-actuator-noweb/src/main/java/sample/actuator/noweb/ServiceProperties.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
package sample.actuator.noweb;
1818

1919
import org.springframework.boot.context.properties.ConfigurationProperties;
20-
import org.springframework.stereotype.Component;
2120

2221
@ConfigurationProperties(prefix = "service", ignoreUnknownFields = false)
23-
@Component
2422
public class ServiceProperties {
2523

24+
/**
25+
* Name of the service.
26+
*/
2627
private String name = "World";
2728

2829
public String getName() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
health.diskspace.enabled: false
1+
health.diskspace.enabled=false

spring-boot-samples/spring-boot-sample-actuator/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ dependencies {
4545
compile("org.springframework.boot:spring-boot-starter-jdbc")
4646
compile("org.springframework.boot:spring-boot-starter-security")
4747
compile("org.springframework.boot:spring-boot-starter-web")
48-
compile("com.h2database:h2")
48+
runtime("com.h2database:h2")
49+
50+
compileOnly('org.springframework.boot:spring-boot-configuration-processor')
4951

5052
testCompile("org.springframework.boot:spring-boot-starter-test")
5153

5254
insecure configurations.runtime
5355
}
5456

55-
// Slightly odd requirement (package a jar file as an insecure app, exlcuding Spring Security)
57+
// Slightly odd requirement (package a jar file as an insecure app, excluding Spring Security)
5658
// just to demonstrate the "customConfiguration" feature of the Boot gradle plugin.
5759
springBoot {
5860
customConfiguration = "insecure"

spring-boot-samples/spring-boot-sample-actuator/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@
3838
<dependency>
3939
<groupId>com.h2database</groupId>
4040
<artifactId>h2</artifactId>
41+
<scope>runtime</scope>
4142
</dependency>
43+
44+
<dependency>
45+
<groupId>org.springframework.boot</groupId>
46+
<artifactId>spring-boot-configuration-processor</artifactId>
47+
<optional>true</optional>
48+
</dependency>
49+
4250
<dependency>
4351
<groupId>org.springframework.boot</groupId>
4452
<artifactId>spring-boot-starter-test</artifactId>

spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/HelloWorldService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616

1717
package sample.actuator;
1818

19-
import org.springframework.beans.factory.annotation.Autowired;
2019
import org.springframework.stereotype.Component;
2120

2221
@Component
2322
public class HelloWorldService {
2423

25-
@Autowired
26-
private ServiceProperties configuration;
24+
private final ServiceProperties configuration;
25+
26+
public HelloWorldService(ServiceProperties configuration) {
27+
this.configuration = configuration;
28+
}
2729

2830
public String getHelloMessage() {
2931
return "Hello " + this.configuration.getName();

spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleActuatorApplication.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,25 @@
2020
import org.springframework.boot.actuate.health.Health;
2121
import org.springframework.boot.actuate.health.HealthIndicator;
2222
import org.springframework.boot.autoconfigure.SpringBootApplication;
23+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
24+
import org.springframework.context.annotation.Bean;
2325

2426
@SpringBootApplication
25-
public class SampleActuatorApplication implements HealthIndicator {
26-
27-
@Override
28-
public Health health() {
29-
return Health.up().withDetail("hello", "world").build();
30-
}
27+
@EnableConfigurationProperties(ServiceProperties.class)
28+
public class SampleActuatorApplication {
3129

3230
public static void main(String[] args) throws Exception {
3331
SpringApplication.run(SampleActuatorApplication.class, args);
3432
}
3533

34+
@Bean
35+
public HealthIndicator helloHealthIndicator() {
36+
return new HealthIndicator() {
37+
@Override
38+
public Health health() {
39+
return Health.up().withDetail("hello", "world").build();
40+
}
41+
};
42+
}
43+
3644
}

spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleController.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import org.hibernate.validator.constraints.NotBlank;
2525

26-
import org.springframework.beans.factory.annotation.Autowired;
2726
import org.springframework.context.annotation.Description;
2827
import org.springframework.stereotype.Controller;
2928
import org.springframework.validation.annotation.Validated;
@@ -36,8 +35,11 @@
3635
@Description("A controller for handling requests for hello messages")
3736
public class SampleController {
3837

39-
@Autowired
40-
private HelloWorldService helloWorldService;
38+
private final HelloWorldService helloWorldService;
39+
40+
public SampleController(HelloWorldService helloWorldService) {
41+
this.helloWorldService = helloWorldService;
42+
}
4143

4244
@GetMapping("/")
4345
@ResponseBody

0 commit comments

Comments
 (0)