From 76c32dcd9b002867fe5229a980c81855c378ca4c Mon Sep 17 00:00:00 2001 From: Erik Pragt Date: Mon, 8 Jul 2019 18:16:25 -0500 Subject: [PATCH] BAEL-2940 Update Spring ComponentScanning. Moved componentscan code to new module. --- pom.xml | 1 + spring-boot-di/pom.xml | 55 +++++++++++++++++++ .../com/baeldung/SpringBootDiApplication.java | 12 ++++ .../baeldung/componentscan/ExampleBean.java | 0 .../springapp/SpringComponentScanApp.java | 4 -- .../componentscan/springapp/animals/Cat.java | 0 .../componentscan/springapp/animals/Dog.java | 0 .../componentscan/springapp/flowers/Rose.java | 0 .../SpringBootComponentScanApp.java | 3 - .../springbootapp/animals/Cat.java | 0 .../springbootapp/animals/Dog.java | 0 .../springbootapp/flowers/Rose.java | 0 spring-boot/.attach_pid12812 | 0 13 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 spring-boot-di/pom.xml create mode 100644 spring-boot-di/src/main/java/com/baeldung/SpringBootDiApplication.java rename {spring-boot => spring-boot-di}/src/main/java/com/baeldung/componentscan/ExampleBean.java (100%) rename {spring-boot => spring-boot-di}/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java (88%) rename {spring-boot => spring-boot-di}/src/main/java/com/baeldung/componentscan/springapp/animals/Cat.java (100%) rename {spring-boot => spring-boot-di}/src/main/java/com/baeldung/componentscan/springapp/animals/Dog.java (100%) rename {spring-boot => spring-boot-di}/src/main/java/com/baeldung/componentscan/springapp/flowers/Rose.java (100%) rename {spring-boot => spring-boot-di}/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java (88%) rename {spring-boot => spring-boot-di}/src/main/java/com/baeldung/componentscan/springbootapp/animals/Cat.java (100%) rename {spring-boot => spring-boot-di}/src/main/java/com/baeldung/componentscan/springbootapp/animals/Dog.java (100%) rename {spring-boot => spring-boot-di}/src/main/java/com/baeldung/componentscan/springbootapp/flowers/Rose.java (100%) delete mode 100644 spring-boot/.attach_pid12812 diff --git a/pom.xml b/pom.xml index b4fed5150d..2d1e2b5291 100644 --- a/pom.xml +++ b/pom.xml @@ -839,6 +839,7 @@ spring-boot-camel spring-boot-client spring-boot-custom-starter + spring-boot-di greeter-spring-boot-autoconfigure greeter-spring-boot-sample-app persistence-modules/spring-boot-h2/spring-boot-h2-database diff --git a/spring-boot-di/pom.xml b/spring-boot-di/pom.xml new file mode 100644 index 0000000000..ec40c04566 --- /dev/null +++ b/spring-boot-di/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + spring-boot-mvc + spring-boot-mvc + jar + Module For Spring Boot DI + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + org.apache.tomcat.embed + tomcat-embed-jasper + provided + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + com.baeldung.SpringBootDiApplication + JAR + + + + + + + com.baeldung.SpringBootDiApplication + + + diff --git a/spring-boot-di/src/main/java/com/baeldung/SpringBootDiApplication.java b/spring-boot-di/src/main/java/com/baeldung/SpringBootDiApplication.java new file mode 100644 index 0000000000..b9d2d7ecef --- /dev/null +++ b/spring-boot-di/src/main/java/com/baeldung/SpringBootDiApplication.java @@ -0,0 +1,12 @@ +package com.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootDiApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootDiApplication.class, args); + } +} diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/ExampleBean.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/ExampleBean.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/componentscan/ExampleBean.java rename to spring-boot-di/src/main/java/com/baeldung/componentscan/ExampleBean.java diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java similarity index 88% rename from spring-boot/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java index 2377ed7a56..83b91f7860 100644 --- a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java @@ -1,10 +1,6 @@ package com.baeldung.componentscan.springapp; -import org.springframework.context.annotation.FilterType; -import org.springframework.stereotype.Component; - import com.baeldung.componentscan.ExampleBean; -import com.baeldung.componentscan.springapp.flowers.Rose; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/animals/Cat.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/animals/Cat.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/componentscan/springapp/animals/Cat.java rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/animals/Cat.java diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/animals/Dog.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/animals/Dog.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/componentscan/springapp/animals/Dog.java rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/animals/Dog.java diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/flowers/Rose.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/flowers/Rose.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/componentscan/springapp/flowers/Rose.java rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/flowers/Rose.java diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java similarity index 88% rename from spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java index ba29a4e1f5..4362caefbb 100644 --- a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java +++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java @@ -1,14 +1,11 @@ package com.baeldung.componentscan.springbootapp; import org.springframework.boot.SpringApplication; -import org.springframework.context.annotation.FilterType; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import com.baeldung.componentscan.ExampleBean; -import com.baeldung.componentscan.springbootapp.flowers.Rose; @SpringBootApplication //@ComponentScan(basePackages = "com.baeldung.componentscan.springbootapp.animals") diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/animals/Cat.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/animals/Cat.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/animals/Cat.java rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/animals/Cat.java diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/animals/Dog.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/animals/Dog.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/animals/Dog.java rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/animals/Dog.java diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/flowers/Rose.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/flowers/Rose.java similarity index 100% rename from spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/flowers/Rose.java rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/flowers/Rose.java diff --git a/spring-boot/.attach_pid12812 b/spring-boot/.attach_pid12812 deleted file mode 100644 index e69de29bb2..0000000000