1.Error creating bean with name 'userController': Unsatisfied dependency ...
UserMapper.xml文件有问题,认真检查xml文件
2.A query was run and no Result Maps were found for the Mapped Statement 'com.
检查xml配置文件的
3.controller返回字符串而不是页面
- 检查controller注释是否是@Controller
- 检查是否添加thymeleaf依赖
org.thymeleaf thymeleaf-spring53.0.11.RELEASE compile org.thymeleaf.extras thymeleaf-extras-java8time3.0.4.RELEASE compile - 检查访问路径和返回路径是否正确
@RequestMapping(value = "/loginIn",method = RequestMethod.POST) public String login(String username,String password){ User user = userService.loginIn(username,password); if(user!=null){ return "success"; }else { return "error1"; } }
4.测试类判断数据库是否连接成功 报错Shutting down ExecutorService
@SpringBootTest
class ScApplicationTests {
@Autowired //检查这个注释是否添加
DataSource dataSource;
@Test
void contextLoads() throws SQLException {
System.out.println(dataSource.getClass());
System.out.println(dataSource.getConnection());
}
}
5.运行报错Parameter 'username' not found. Available parameters are [arg1, arg0, param1, param2]
解决办法:
- 在实现方法参数前添加@Param("xxx")
public String login(@Param("username")String username, @Param("password")String password){...}
- 在xml配置文件中用 arg0 和 arg1 代替参数名称



