public static ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");写进一个专门的类里。以后直接用就行了。