--- /dev/null
+package de.juplo.boot.conditional.boot;
+
+import de.juplo.boot.conditional.lib.DefaultConfig;
+import de.juplo.boot.conditional.lib.SpecializedConfig;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Import;
+
+
+@SpringBootApplication
+@Import({
+ SpecializedConfig.class,
+ DefaultConfig.class,
+})
+public class Application
+{
+ public static void main(String[] args)
+ {
+ SpringApplication.run(Application.class, args);
+ }
+}
--- /dev/null
+package de.juplo.boot.conditional.lib;
+
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+
+@Slf4j
+public final class BeanA
+{
+ @Getter
+ private final String name;
+
+ public BeanA(String name)
+ {
+ this.name = name;
+ log.info("BeanA was instanciated: {}", name);
+ }
+}
--- /dev/null
+package de.juplo.boot.conditional.lib;
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+@Configuration
+public class DefaultConfig
+{
+ @ConditionalOnMissingBean()
+ @Bean
+ public BeanA beanA()
+ {
+ return new BeanA("Default for BeanA");
+ }
+}
--- /dev/null
+package de.juplo.boot.conditional.lib;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+@Configuration
+public class SpecializedConfig
+{
+ @Bean
+ public BeanA beanA()
+ {
+ return new BeanA("Specialized BeanA");
+ }
+}
--- /dev/null
+package de.juplo.boot.conditional.spring;
+
+import de.juplo.boot.conditional.lib.DefaultConfig;
+import de.juplo.boot.conditional.lib.SpecializedConfig;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+
+@Configuration
+@Import({
+ SpecializedConfig.class,
+ DefaultConfig.class,
+})
+public class Application
+{
+ public static void main(String[] args)
+ {
+ ApplicationContext context =
+ new AnnotationConfigApplicationContext(Application.class);
+ }
+}