From b3ea4cf205acf29b00b04e5339c67b1dbd7f635d Mon Sep 17 00:00:00 2001 From: javahongxi Date: Sat, 15 Aug 2020 10:35:31 +0800 Subject: [PATCH] environment --- .../beans/autoconfigure/ApplicationConfiguration.java | 1 + .../sample/beans/environment/EnvironmentProcessor.java | 2 ++ .../src/main/resources/application.yml | 7 ++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/java/org/hongxi/whatsmars/boot/sample/beans/autoconfigure/ApplicationConfiguration.java b/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/java/org/hongxi/whatsmars/boot/sample/beans/autoconfigure/ApplicationConfiguration.java index bd1ae1a5..bde66eb4 100644 --- a/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/java/org/hongxi/whatsmars/boot/sample/beans/autoconfigure/ApplicationConfiguration.java +++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/java/org/hongxi/whatsmars/boot/sample/beans/autoconfigure/ApplicationConfiguration.java @@ -50,6 +50,7 @@ public class ApplicationConfiguration { @Bean @Conditional(OrCondition.class) + @ConditionalOnProperty(prefix = "mars", name = {"provider.dubbo-port", "provider.log-path"}) public ConditionalBean conditionalBean() { return new ConditionalBean(); } diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/java/org/hongxi/whatsmars/boot/sample/beans/environment/EnvironmentProcessor.java b/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/java/org/hongxi/whatsmars/boot/sample/beans/environment/EnvironmentProcessor.java index 4039fa70..c06b6b7a 100644 --- a/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/java/org/hongxi/whatsmars/boot/sample/beans/environment/EnvironmentProcessor.java +++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/java/org/hongxi/whatsmars/boot/sample/beans/environment/EnvironmentProcessor.java @@ -8,5 +8,7 @@ public class EnvironmentProcessor implements EnvironmentPostProcessor { @Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { System.out.println("postProcessEnvironment"); + System.setProperty("mars.consumer.dubboPort", "2000"); + System.out.println(environment.getProperty("mars.consumer.dubbo-port")); } } \ No newline at end of file diff --git a/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/resources/application.yml b/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/resources/application.yml index 7ad44bf4..062fe8e4 100644 --- a/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/resources/application.yml +++ b/whatsmars-spring-boot-samples/whatsmars-boot-sample-beans/src/main/resources/application.yml @@ -11,4 +11,9 @@ test: second: 2 properties: a: x - b: y \ No newline at end of file + b: y + +mars: + provider: + dubboPort: 2000 + logPath: /tmp/logs \ No newline at end of file -- GitLab