mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '2.6.x' into 2.7.x
Closes gh-31270
This commit is contained in:
commit
a0fee42740
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class HelloWorldService {
|
public class HelloWorldService {
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public String getHelloMessage() {
|
public String getHelloMessage() {
|
||||||
|
@ -1 +1 @@
|
|||||||
name: Phil
|
test.name: Phil
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -60,7 +60,7 @@ class SampleAopApplicationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCommandLineOverrides(CapturedOutput output) {
|
void testCommandLineOverrides(CapturedOutput output) {
|
||||||
SampleAopApplication.main(new String[] { "--name=Gordon" });
|
SampleAopApplication.main(new String[] { "--test.name=Gordon" });
|
||||||
assertThat(output).contains("Hello Gordon");
|
assertThat(output).contains("Hello Gordon");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class HelloWorldService {
|
public class HelloWorldService {
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public String getHelloMessage() {
|
public String getHelloMessage() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class HelloWorldService {
|
public class HelloWorldService {
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public String getHelloMessage() {
|
public String getHelloMessage() {
|
||||||
|
@ -1 +1 @@
|
|||||||
hello: Bonjour
|
test.hello: Bonjour
|
||||||
|
@ -30,7 +30,7 @@ public class SampleProfileApplication implements CommandLineRunner {
|
|||||||
|
|
||||||
// Simple example shows how a command line spring application can execute an
|
// Simple example shows how a command line spring application can execute an
|
||||||
// injected bean service. Also demonstrates how you can use @Value to inject
|
// injected bean service. Also demonstrates how you can use @Value to inject
|
||||||
// command line args ('--name=whatever') or application properties
|
// command line args ('--test.name=whatever') or application properties
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MessageService helloWorldService;
|
private MessageService helloWorldService;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,10 +24,10 @@ import org.springframework.stereotype.Component;
|
|||||||
@Profile({ "generic" })
|
@Profile({ "generic" })
|
||||||
public class GenericService implements MessageService {
|
public class GenericService implements MessageService {
|
||||||
|
|
||||||
@Value("${hello:Hello}")
|
@Value("${test.hello:Hello}")
|
||||||
private String hello;
|
private String hello;
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,7 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Profile("goodbye")
|
@Profile("goodbye")
|
||||||
public class GoodbyeWorldService implements MessageService {
|
public class GoodbyeWorldService implements MessageService {
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,7 +24,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Profile({ "hello", "default" })
|
@Profile({ "hello", "default" })
|
||||||
public class HelloWorldService implements MessageService {
|
public class HelloWorldService implements MessageService {
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Phil
|
test.name: Phil
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
spring.config.activate.on-profile: goodbye | dev
|
spring.config.activate.on-profile: goodbye | dev
|
||||||
name: Everyone
|
test.name: Everyone
|
||||||
|
@ -65,7 +65,7 @@ class SampleProfileApplicationTests {
|
|||||||
* This is a profile that requires a new environment property, and one which is
|
* This is a profile that requires a new environment property, and one which is
|
||||||
* only overridden in the current working directory. That file also only contains
|
* only overridden in the current working directory. That file also only contains
|
||||||
* partial overrides, and the default application.yml should still supply the
|
* partial overrides, and the default application.yml should still supply the
|
||||||
* "name" property.
|
* "test.name" property.
|
||||||
*/
|
*/
|
||||||
System.setProperty("spring.profiles.active", "generic");
|
System.setProperty("spring.profiles.active", "generic");
|
||||||
SampleProfileApplication.main();
|
SampleProfileApplication.main();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -30,7 +30,7 @@ public class SampleSimpleApplication implements CommandLineRunner {
|
|||||||
|
|
||||||
// Simple example shows how a command line spring application can execute an
|
// Simple example shows how a command line spring application can execute an
|
||||||
// injected bean service. Also demonstrates how you can use @Value to inject
|
// injected bean service. Also demonstrates how you can use @Value to inject
|
||||||
// command line args ('--name=whatever') or application properties
|
// command line args ('--test.name=whatever') or application properties
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HelloWorldService helloWorldService;
|
private HelloWorldService helloWorldService;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,10 +24,10 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class HelloWorldService {
|
public class HelloWorldService {
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Value("${duration:10s}")
|
@Value("${test.duration:10s}")
|
||||||
private Duration duration;
|
private Duration duration;
|
||||||
|
|
||||||
public String getHelloMessage() {
|
public String getHelloMessage() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name=Phil
|
test.name=Phil
|
||||||
sample.name=Andy
|
sample.name=Andy
|
||||||
|
|
||||||
spring.banner.image.bitdepth=8
|
spring.banner.image.bitdepth=8
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -60,7 +60,7 @@ class SampleSimpleApplicationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCommandLineOverrides(CapturedOutput output) {
|
void testCommandLineOverrides(CapturedOutput output) {
|
||||||
SampleSimpleApplication.main(new String[] { "--name=Gordon", "--duration=1m" });
|
SampleSimpleApplication.main(new String[] { "--test.name=Gordon", "--test.duration=1m" });
|
||||||
assertThat(output).contains("Hello Gordon for 60 seconds");
|
assertThat(output).contains("Hello Gordon for 60 seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class HelloWorldService {
|
public class HelloWorldService {
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public String getHelloMessage() {
|
public String getHelloMessage() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class HelloWorldService {
|
public class HelloWorldService {
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public String getHelloMessage() {
|
public String getHelloMessage() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class HelloWorldService {
|
public class HelloWorldService {
|
||||||
|
|
||||||
@Value("${name:World}")
|
@Value("${test.name:World}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public String getHelloMessage() {
|
public String getHelloMessage() {
|
||||||
|
Loading…
Reference in New Issue
Block a user