Refined bean methods
This commit is contained in:
parent
427581b3a6
commit
14593ca02a
|
@ -8,18 +8,19 @@ 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"},
|
||||
//@Configuration
|
||||
@ComponentScan(basePackages = {"com.baeldung.annotations.componentscanautoconfigure.healthcare", "com.baeldung.annotations.componentscanautoconfigure.employee"},
|
||||
basePackageClasses = Teacher.class)
|
||||
@EnableAutoConfiguration(exclude={JdbcTemplateAutoConfiguration.class})
|
||||
@EnableAutoConfiguration(exclude = {JdbcTemplateAutoConfiguration.class})
|
||||
//@EnableAutoConfiguration(excludeName = {"org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration"})
|
||||
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 Doctor: " + context.containsBeanDefinition("doctor"));
|
||||
System.out.println("Configures Hospital: " + context.containsBeanDefinition("hospital"));
|
||||
System.out.println("Configures Student: " + context.containsBeanDefinition("student"));
|
||||
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;
|
||||
|
||||
@Component("seniorEmployee")
|
||||
@Component
|
||||
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…
Reference in New Issue