package com.storage.test; import org.junit.Before; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.storage.dao.UserDAO; public class TestUser { ClassPathXmlApplicationContext ctx; @Before public void init(){ ctx = new ClassPathXmlApplicationContext("applicationContext.xml","mybatis.xml"); } @Test public void testAddUser(){ UserDAO userDAO = ctx.getBean("UserDAO",UserDAO.class); userDAO.addUser("admin", "admin"); } }