parent
2a85427324
commit
073f8c4b23
|
@ -95,7 +95,7 @@ For instance, the following example loads a YAML configuration file from the cla
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{include-howto}/springbootapplication/ExampleEnvironmentPostProcessor.java[tag=*]
|
||||
include::{include-howto}/springbootapplication/MyEnvironmentPostProcessor.java[tag=*]
|
||||
----
|
||||
|
||||
TIP: The `Environment` has already been prepared with all the usual property sources that Spring Boot loads by default.
|
||||
|
|
|
@ -463,7 +463,7 @@ The following example exposes a read operation that returns a custom object:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{include-productionreadyfeatures}/endpoints/CustomEndpointExample.java[tag=read]
|
||||
include::{include-productionreadyfeatures}/endpoints/CustomEndpoint.java[tag=read]
|
||||
----
|
||||
|
||||
You can also write technology-specific endpoints by using `@JmxEndpoint` or `@WebEndpoint`.
|
||||
|
@ -500,7 +500,7 @@ This can be used to invoke a write operation that takes `String name` and `int c
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{include-productionreadyfeatures}/endpoints/CustomEndpointExample.java[tag=write]
|
||||
include::{include-productionreadyfeatures}/endpoints/CustomEndpoint.java[tag=write]
|
||||
----
|
||||
|
||||
TIP: Because endpoints are technology agnostic, only simple types can be specified in the method signature.
|
||||
|
|
|
@ -436,7 +436,7 @@ This exit code can then be passed to `System.exit()` to return it as a status co
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{include-springbootfeatures}/springapplication/ExitCodeExample.java[tag=*]
|
||||
include::{include-springbootfeatures}/springapplication/exitcode/MyApplication.java[tag=*]
|
||||
----
|
||||
|
||||
Also, the `ExitCodeGenerator` interface may be implemented by exceptions.
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.springframework.core.io.ClassPathResource;
|
|||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
public class ExampleEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
public class MyEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
|
||||
private final YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
|
||||
|
|
@ -21,7 +21,7 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
|||
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
|
||||
|
||||
@Endpoint(id = "custom")
|
||||
public class CustomEndpointExample {
|
||||
public class CustomEndpoint {
|
||||
|
||||
// tag::read[]
|
||||
@ReadOperation
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.springbootfeatures.springapplication;
|
||||
package org.springframework.boot.docs.springbootfeatures.springapplication.exitcode;
|
||||
|
||||
// tag::code[]
|
||||
import org.springframework.boot.ExitCodeGenerator;
|
||||
|
@ -23,7 +23,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ExitCodeExample {
|
||||
public class MyApplication {
|
||||
|
||||
@Bean
|
||||
public ExitCodeGenerator exitCodeGenerator() {
|
||||
|
@ -31,7 +31,7 @@ public class ExitCodeExample {
|
|||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.exit(SpringApplication.exit(SpringApplication.run(ExitCodeExample.class, args)));
|
||||
System.exit(SpringApplication.exit(SpringApplication.run(MyApplication.class, args)));
|
||||
}
|
||||
|
||||
}
|
|
@ -24,18 +24,18 @@ import org.springframework.core.env.StandardEnvironment;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ExampleEnvironmentPostProcessor}.
|
||||
* Tests for {@link MyEnvironmentPostProcessor}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class ExampleEnvironmentPostProcessorTests {
|
||||
class MyEnvironmentPostProcessorTests {
|
||||
|
||||
private final StandardEnvironment environment = new StandardEnvironment();
|
||||
|
||||
@Test
|
||||
void applyEnvironmentPostProcessor() {
|
||||
assertThat(this.environment.containsProperty("test.foo.bar")).isFalse();
|
||||
new ExampleEnvironmentPostProcessor().postProcessEnvironment(this.environment, new SpringApplication());
|
||||
new MyEnvironmentPostProcessor().postProcessEnvironment(this.environment, new SpringApplication());
|
||||
assertThat(this.environment.containsProperty("test.foo.bar")).isTrue();
|
||||
assertThat(this.environment.getProperty("test.foo.bar")).isEqualTo("value");
|
||||
}
|
Loading…
Reference in New Issue