1. 构建项目:
2.添加依赖
<dependencies> <dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.7</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies>
3.Model 准备
public interface UserService {User login(String usrName, String usrPassword);int addUser(User user);int deleteUser(Long usrId);int updateUser(User user);User getUser(Long usrId);List<User> findAllUsers();
}
5.2 控制器开发
5.2.1 JSON的支持
@Controller
public class UserController {@Resourceprivate UserService userService;@RequestMapping(value = "/getUser",method = RequestMethod.GET)public User getUser(Long usrId){User user = userService.getUser(usrId);return user;}
}