eclipse整合mybatis和spring boot实现访问数据库
具体操作如下:
https://www.jb51.net/article/157364.htm
注意的点如下:
user.xml 里面要配正确例如
mapper namespace=“com.lee.test.mapper.UserMapper”
配置在application.properties中如下
server.port=8080
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/user_db?useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=123456
mybatis.mapper-locations=classpath:mapper/*.xml
最后访问:http://localhost:8080/getUser/1
主要还是格式要正确,路径正确
@RequestMapping(“list”)
public List index() throws Exception {
return userService.getUser();
}
//删除用户删除用户
@RequestMapping(“delete/{id}”)
public String delete(@PathVariable int id) throw