From 04821a0a85c63c923bdd839c49fcc3aaf2ef27c2 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 20 Nov 2020 22:58:27 +0100 Subject: [PATCH] WIP --- .../multiplebeans/MultipleBeansApplication.java | 1 + ...ltipleBeansApplicationContextInitializer.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplicationContextInitializer.java diff --git a/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplication.java b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplication.java index cafcacf..7da4fa0 100644 --- a/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplication.java +++ b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplication.java @@ -7,6 +7,7 @@ import org.springframework.context.annotation.Bean; @SpringBootApplication @EnableConfigurationProperties(MultipleBeansProperties.class) +@ContextConfiguration() public class MultipleBeansApplication { @Bean(name = "/peter") diff --git a/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplicationContextInitializer.java b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplicationContextInitializer.java new file mode 100644 index 0000000..f6d4ecf --- /dev/null +++ b/src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplicationContextInitializer.java @@ -0,0 +1,16 @@ +package de.juplo.demos.multiplebeans; + +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.stereotype.Component; + +public class MultipleBeansApplicationContextInitializer + implements + ApplicationContextInitializer { + + @Override + public void initialize(ConfigurableApplicationContext context) { + MultipleBeansProperties properties = context.getBean(MultipleBeansProperties.class); + System.out.println(properties.project); + } +} -- 2.20.1