From 24b105c665fd11d97e6a00a058b9150b9c855d8c Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 20 Nov 2020 23:55:33 +0100 Subject: [PATCH] WIP --- ...MultipleBeansEnvironmentPostProcessor.java | 20 +++++++++++++++++++ src/main/resources/META-INF/spring.factories | 2 +- src/main/resources/application.yml | 5 ++++- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/juplo/demos/multiplebeans/MultipleBeansEnvironmentPostProcessor.java diff --git a/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansEnvironmentPostProcessor.java b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansEnvironmentPostProcessor.java new file mode 100644 index 0000000..132f6ee --- /dev/null +++ b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansEnvironmentPostProcessor.java @@ -0,0 +1,20 @@ +package de.juplo.demos.multiplebeans; + +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.env.EnvironmentPostProcessor; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.PropertySource; + +import java.util.regex.Pattern; + +public class MultipleBeansEnvironmentPostProcessor implements EnvironmentPostProcessor { + public final static Pattern PATTERN = Pattern.compile("juplo\\.sites\\[([0-9]+)\\]\\.(.+)"); + + @Override + public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { + for (PropertySource source : environment.getPropertySources()) { + System.out.println(source.getName()); + } + } +} diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories index 5c9c458..05adff8 100644 --- a/src/main/resources/META-INF/spring.factories +++ b/src/main/resources/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.context.ApplicationContextInitializer=de.juplo.demos.multiplebeans.MultipleBeansApplicationContextInitializer +org.springframework.boot.env.EnvironmentPostProcessor=de.juplo.demos.multiplebeans.MultipleBeansEnvironmentPostProcessor \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 04397c1..87bec8d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,4 +3,7 @@ juplo: sites: - name: peter description: This is the Home-Page of PETER - + - name: ute + description: My name is Ute. I like cats! + - name: franz + description: Franz was here! -- 2.20.1