Using Spring 3 autowire in a standalone Java application
问题 Here is my code: public class Main { public static void main(String[] args) { Main p = new Main(); p.start(args); } @Autowired private MyBean myBean; private void start(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/config.xml"); System.out.println("my beans method: " + myBean.getStr()); } } @Service public class MyBean { public String getStr() { return "string"; } } <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3