public class Main { private static final Logger log = LoggerFactory.getLogger(Main.class); public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext([ProjectContext].class); try { UserService userService = context.getBean(UserService.class); } finally { context.close(); } } }
@Autowired DefaultListableBeanFactory bf; for (String name : bf.getBeanDefinitionNames()) { System.out.println(name + "\t" + bf.getBean(name).getClass().getCanonicalName()); }
동일한 이름의 Bean을 동일 컨텍스트(부모/자식간 말고)에서 여러번 생성할 경우 앞서 생성된 것을 Override 해버린다. java - Defining the same Spring bean twice with same name