Refined bean methods
This commit is contained in:
parent
427581b3a6
commit
14593ca02a
@ -8,8 +8,8 @@ import org.springframework.context.ApplicationContext;
|
|||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
//@Configuration
|
||||||
@ComponentScan(basePackages = {"com.baeldung.annotations.componentscanautoconfigure.doctor", "com.baeldung.annotations.componentscanautoconfigure.employee"},
|
@ComponentScan(basePackages = {"com.baeldung.annotations.componentscanautoconfigure.healthcare", "com.baeldung.annotations.componentscanautoconfigure.employee"},
|
||||||
basePackageClasses = Teacher.class)
|
basePackageClasses = Teacher.class)
|
||||||
@EnableAutoConfiguration(exclude = {JdbcTemplateAutoConfiguration.class})
|
@EnableAutoConfiguration(exclude = {JdbcTemplateAutoConfiguration.class})
|
||||||
//@EnableAutoConfiguration(excludeName = {"org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration"})
|
//@EnableAutoConfiguration(excludeName = {"org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration"})
|
||||||
@ -17,9 +17,10 @@ public class EmployeeApplication {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ApplicationContext context = SpringApplication.run(EmployeeApplication.class, 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 Employee: " + context.containsBeanDefinition("employee"));
|
||||||
System.out.println("Configures Senior Employee: " + context.containsBeanDefinition("seniorEmployee"));
|
System.out.println("Configures Senior Employee: " + context.containsBeanDefinition("seniorEmployee"));
|
||||||
|
System.out.println("Configures Doctor: " + context.containsBeanDefinition("doctor"));
|
||||||
|
System.out.println("Configures Hospital: " + context.containsBeanDefinition("hospital"));
|
||||||
System.out.println("Configures Student: " + context.containsBeanDefinition("student"));
|
System.out.println("Configures Student: " + context.containsBeanDefinition("student"));
|
||||||
System.out.println("Configures Teacher: " + context.containsBeanDefinition("teacher"));
|
System.out.println("Configures Teacher: " + context.containsBeanDefinition("teacher"));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package com.baeldung.annotations.componentscanautoconfigure.doctor;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component("doctor")
|
|
||||||
public class Doctor {
|
|
||||||
}
|
|
@ -2,6 +2,6 @@ package com.baeldung.annotations.componentscanautoconfigure.employee;
|
|||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component("seniorEmployee")
|
@Component
|
||||||
public class SeniorEmployee {
|
public class SeniorEmployee {
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.baeldung.annotations.componentscanautoconfigure.healthcare;
|
||||||
|
|
||||||
|
public class Doctor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Doctor" + this.hashCode();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.baeldung.annotations.componentscanautoconfigure.healthcare;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class Hospital {
|
||||||
|
|
||||||
|
@Bean("doctor")
|
||||||
|
public Doctor getDoctor() {
|
||||||
|
return new Doctor();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user