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

+7
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

+5-3
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

+2
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

+3-2
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() {
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

+4-2
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

+8
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

+5-3
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

+14-6
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

+5-3
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

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
package sample.actuator;
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() {

spring-boot-samples/spring-boot-sample-cache/src/main/resources/application.properties

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
management.security.enabled=false
2+
13
#
24
# Infinispan configuration file location.
35
#

spring-boot-samples/spring-boot-sample-data-couchbase/pom.xml

+2-13
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,12 @@
1818
<main.basedir>${basedir}/../..</main.basedir>
1919
</properties>
2020
<dependencies>
21-
<dependency>
22-
<groupId>org.springframework.boot</groupId>
23-
<artifactId>spring-boot-starter</artifactId>
24-
</dependency>
2521
<dependency>
2622
<groupId>org.springframework.boot</groupId>
2723
<artifactId>spring-boot-starter-data-couchbase</artifactId>
2824
</dependency>
29-
<dependency>
30-
<groupId>org.springframework.boot</groupId>
31-
<artifactId>spring-boot-starter-web</artifactId>
32-
</dependency>
33-
<dependency>
34-
<groupId>org.springframework.boot</groupId>
35-
<artifactId>spring-boot-actuator</artifactId>
36-
</dependency>
37-
<dependency>
25+
26+
<dependency>
3827
<groupId>org.springframework.boot</groupId>
3928
<artifactId>spring-boot-starter-test</artifactId>
4029
<scope>test</scope>

spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/SampleFlywayApplication.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,26 @@
1616

1717
package sample.flyway;
1818

19-
import org.springframework.beans.factory.annotation.Autowired;
2019
import org.springframework.boot.CommandLineRunner;
2120
import org.springframework.boot.SpringApplication;
2221
import org.springframework.boot.autoconfigure.SpringBootApplication;
22+
import org.springframework.context.annotation.Bean;
2323

2424
@SpringBootApplication
25-
public class SampleFlywayApplication implements CommandLineRunner {
26-
27-
@Autowired
28-
private PersonRepository repository;
29-
30-
@Override
31-
public void run(String... args) throws Exception {
32-
System.err.println(this.repository.findAll());
33-
}
25+
public class SampleFlywayApplication {
3426

3527
public static void main(String[] args) throws Exception {
3628
SpringApplication.run(SampleFlywayApplication.class, args);
3729
}
3830

31+
@Bean
32+
public CommandLineRunner runner(final PersonRepository repository) {
33+
return new CommandLineRunner() {
34+
@Override
35+
public void run(String... args) throws Exception {
36+
System.err.println(repository.findAll());
37+
}
38+
};
39+
}
40+
3941
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
management.security.enabled=false
2+
13
spring.jpa.hibernate.ddl-auto=validate
24

35
spring.h2.console.enabled=true
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# management.context-path=/admin
2-
spring.http.converters.preferred-json-mapper: gson
2+
management.security.enabled=false
3+
4+
spring.http.converters.preferred-json-mapper=gson

spring-boot-samples/spring-boot-sample-hypermedia-gson/src/test/java/sample/hypermedia/gson/SampleHypermediaGsonApplicationTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535

3636
@RunWith(SpringRunner.class)
3737
@SpringBootTest
38-
@TestPropertySource(properties = { "endpoints.hypermedia.enabled: true",
39-
"management.security.enabled: false" })
38+
@TestPropertySource(properties = "endpoints.hypermedia.enabled: true")
4039
public class SampleHypermediaGsonApplicationTests {
4140

4241
@Autowired

spring-boot-samples/spring-boot-sample-hypermedia-jpa/src/test/java/sample/hypermedia/jpa/SampleHypermediaJpaApplicationIntegrationTests.java

+2-12
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,16 @@
1616

1717
package sample.hypermedia.jpa;
1818

19-
import org.junit.Before;
2019
import org.junit.Test;
2120
import org.junit.runner.RunWith;
2221

2322
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
2424
import org.springframework.boot.test.context.SpringBootTest;
2525
import org.springframework.http.MediaType;
26-
import org.springframework.test.annotation.DirtiesContext;
2726
import org.springframework.test.context.junit4.SpringRunner;
2827
import org.springframework.test.web.servlet.MockMvc;
2928
import org.springframework.test.web.servlet.MvcResult;
30-
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
31-
import org.springframework.web.context.WebApplicationContext;
3229

3330
import static org.assertj.core.api.Assertions.assertThat;
3431
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@@ -37,19 +34,12 @@
3734

3835
@RunWith(SpringRunner.class)
3936
@SpringBootTest
40-
@DirtiesContext
37+
@AutoConfigureMockMvc
4138
public class SampleHypermediaJpaApplicationIntegrationTests {
4239

4340
@Autowired
44-
private WebApplicationContext context;
45-
4641
private MockMvc mockMvc;
4742

48-
@Before
49-
public void setUp() {
50-
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
51-
}
52-
5343
@Test
5444
public void links() throws Exception {
5545
this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))

spring-boot-samples/spring-boot-sample-hypermedia-jpa/src/test/java/sample/hypermedia/jpa/SampleHypermediaJpaApplicationTests.java

-35
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
management.security.enabled=false
2+
13
management.context-path=/admin
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# management.context-path=/admin
2+
management.security.enabled=false
3+
24
endpoints.docs.curies.enabled=true

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@
2323
<groupId>org.springframework.boot</groupId>
2424
<artifactId>spring-boot-starter-integration</artifactId>
2525
</dependency>
26-
<dependency>
27-
<groupId>org.springframework.boot</groupId>
28-
<artifactId>spring-boot-starter-actuator</artifactId>
29-
</dependency>
3026
<dependency>
3127
<groupId>org.springframework.integration</groupId>
3228
<artifactId>spring-integration-file</artifactId>
3329
</dependency>
30+
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-configuration-processor</artifactId>
34+
<optional>true</optional>
35+
</dependency>
36+
3437
<dependency>
3538
<groupId>org.springframework.boot</groupId>
3639
<artifactId>spring-boot-starter-test</artifactId>

0 commit comments

Comments
 (0)