springboot项目 sql列名为什么不能相同,SSM里就没有问题
展开全部
如题。service中注入mapper接口都可以正常获取数据。在写service的单元测试时无法注入mapper接口。
service测试类如下:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = TestRunner.class)
public class LoginServiceTest {
@Autowired
private UserMapper userMapper;
@Test
public void isLogin() throws Exception {
User user = new User();
user.setUserName("wangjing");
user.setPassword("1234");
Assert.assertEquals(1,userMapper.isLogin(user));
}
}
service测试类如下:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = TestRunner.class)
public class LoginServiceTest {
@Autowired
private UserMapper userMapper;
@Test
public void isLogin() throws Exception {
User user = new User();
user.setUserName("wangjing");
user.setPassword("1234");
Assert.assertEquals(1,userMapper.isLogin(user));
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询