首先
抛出Failed to load ApplicationContext异常
百度后,@ContextConfiguration(“classpath:application.xml”)和@Autowired都写好的,但是就是出错
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:application.xml")
public class IEmployeeServiceImplTest {
@Autowired
private IEmployeeService iEmployeeService;
@Test
public void save() {
Employee employee = new Employee();
employee.setId(51L);
employee.setUsername("网二码子");
iEmployeeService.save(employee);
}
}
仔细查看整个测试信息拉到最右边发现找不到一个class
原因:给class取了别名
@Alias("Department")
public class Department
在Mapper.xml中使用
<association property="dept" javaType="Department" columnPrefix="dept_">
<id column="id" property="id"></id>
<result column="name" property="name"></result>
</association>
改成
<association property="dept" javaType="com._520it.crm.domain.Department" columnPrefix="dept_">
<id column="id" property="id"></id>
<result column="name" property="name"></result>
</association>
即测试成功