WIP
authorKai Moritz <kai@juplo.de>
Fri, 20 Nov 2020 21:58:27 +0000 (22:58 +0100)
committerKai Moritz <kai@juplo.de>
Fri, 20 Nov 2020 22:01:33 +0000 (23:01 +0100)
src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplication.java
src/main/java/de/juplo/demos/multiplebeans/MultipleBeansApplicationContextInitializer.java [new file with mode: 0644]

index cafcacf..7da4fa0 100644 (file)
@@ -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 (file)
index 0000000..f6d4ecf
--- /dev/null
@@ -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<ConfigurableApplicationContext> {
+
+    @Override
+    public void initialize(ConfigurableApplicationContext context) {
+        MultipleBeansProperties properties = context.getBean(MultipleBeansProperties.class);
+        System.out.println(properties.project);
+    }
+}