我没有使用@import
注释,虽然上下文能够加载bean(SalesService)它应该抛出异常找到代码。
@SpringBootApplication
public class App {
public static void main(String[] args) {
ApplicationContext context = (ApplicationContext) SpringApplication.run(CustomerConfig.class);
CustomerService customer = (CustomerService) context.getBean("customerBean");
customer.printMessage("setting message for CustomerService");
SalesService sales = (SalesService)context.getBean("salesBean");
sales.printMessage("setting message for SalesService");
}
}