mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Merge branch '2.7.x'
Closes gh-31271
This commit is contained in:
commit
ab93bc26c7
@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class HelloWorldService {
|
||||
|
||||
@Value("${name:World}")
|
||||
@Value("${test.name:World}")
|
||||
private String name;
|
||||
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -60,7 +60,7 @@ class SampleAopApplicationTests {
|
||||
|
||||
@Test
|
||||
void testCommandLineOverrides(CapturedOutput output) {
|
||||
SampleAopApplication.main(new String[] { "--name=Gordon" });
|
||||
SampleAopApplication.main(new String[] { "--test.name=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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class HelloWorldService {
|
||||
|
||||
@Value("${name:World}")
|
||||
@Value("${test.name:World}")
|
||||
private String name;
|
||||
|
||||
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
|
||||
// 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
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -24,10 +24,10 @@ import org.springframework.stereotype.Component;
|
||||
@Profile({ "generic" })
|
||||
public class GenericService implements MessageService {
|
||||
|
||||
@Value("${hello:Hello}")
|
||||
@Value("${test.hello:Hello}")
|
||||
private String hello;
|
||||
|
||||
@Value("${name:World}")
|
||||
@Value("${test.name:World}")
|
||||
private String name;
|
||||
|
||||
@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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -24,7 +24,7 @@ import org.springframework.stereotype.Component;
|
||||
@Profile("goodbye")
|
||||
public class GoodbyeWorldService implements MessageService {
|
||||
|
||||
@Value("${name:World}")
|
||||
@Value("${test.name:World}")
|
||||
private String name;
|
||||
|
||||
@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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -24,7 +24,7 @@ import org.springframework.stereotype.Component;
|
||||
@Profile({ "hello", "default" })
|
||||
public class HelloWorldService implements MessageService {
|
||||
|
||||
@Value("${name:World}")
|
||||
@Value("${test.name:World}")
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: Phil
|
||||
test.name: Phil
|
||||
|
||||
---
|
||||
|
||||
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
|
||||
* only overridden in the current working directory. That file also only contains
|
||||
* partial overrides, and the default application.yml should still supply the
|
||||
* "name" property.
|
||||
* "test.name" property.
|
||||
*/
|
||||
System.setProperty("spring.profiles.active", "generic");
|
||||
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");
|
||||
* 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
|
||||
// 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
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -24,10 +24,10 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class HelloWorldService {
|
||||
|
||||
@Value("${name:World}")
|
||||
@Value("${test.name:World}")
|
||||
private String name;
|
||||
|
||||
@Value("${duration:10s}")
|
||||
@Value("${test.duration:10s}")
|
||||
private Duration duration;
|
||||
|
||||
public String getHelloMessage() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
name=Phil
|
||||
test.name=Phil
|
||||
sample.name=Andy
|
||||
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -60,7 +60,7 @@ class SampleSimpleApplicationTests {
|
||||
|
||||
@Test
|
||||
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");
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class HelloWorldService {
|
||||
|
||||
@Value("${name:World}")
|
||||
@Value("${test.name:World}")
|
||||
private String name;
|
||||
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class HelloWorldService {
|
||||
|
||||
@Value("${name:World}")
|
||||
@Value("${test.name:World}")
|
||||
private String name;
|
||||
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class HelloWorldService {
|
||||
|
||||
@Value("${name:World}")
|
||||
@Value("${test.name:World}")
|
||||
private String name;
|
||||
|
||||
public String getHelloMessage() {
|
||||
|
Loading…
Reference in New Issue
Block a user