Added component scan and auto configuration annotations
This commit is contained in:
parent
e3d721b72c
commit
29c91cde2e
@ -0,0 +1,26 @@
|
||||
package com.baeldung.annotations.componentscanautoconfigure;
|
||||
|
||||
import com.baeldung.annotations.componentscanautoconfigure.teacher.Teacher;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.aop.AopAutoConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {"com.baeldung.annotations.componentscanautoconfigure.doctor", "com.baeldung.annotations.componentscanautoconfigure.employee"},
|
||||
basePackageClasses = Teacher.class)
|
||||
@EnableAutoConfiguration(exclude={AopAutoConfiguration.class})
|
||||
//@EnableAutoConfiguration(excludeName = {"org.springframework.boot.autoconfigure.aop"})
|
||||
public class EmployeeApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ApplicationContext context = SpringApplication.run(EmployeeApplication.class, args);
|
||||
System.out.println("Configures Doctor: " + context.containsBeanDefinition("doctor"));
|
||||
System.out.println("Configures Employee: " + context.containsBeanDefinition("employee"));
|
||||
System.out.println("Configures Senior Employee: " + context.containsBeanDefinition("seniorEmployee"));
|
||||
System.out.println("Configures Student: " + context.containsBeanDefinition("student"));
|
||||
System.out.println("Configures Teacher: " + context.containsBeanDefinition("teacher"));
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.baeldung.annotations.componentscanautoconfigure.doctor;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("doctor")
|
||||
public class Doctor {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.baeldung.annotations.componentscanautoconfigure.employee;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("employee")
|
||||
public class Employee {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.baeldung.annotations.componentscanautoconfigure.employee;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("seniorEmployee")
|
||||
public class SeniorEmployee {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.baeldung.annotations.componentscanautoconfigure.student;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("student")
|
||||
public class Student {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.baeldung.annotations.componentscanautoconfigure.teacher;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component("teacher")
|
||||
public class Teacher {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user