1. The running problem of the cloned project
1.1.maven dependency plug-in problem
1.2. Prompt Cannot start complier
Reason: missing out directory
2. Spring Boot project startup and operation problems
2. Code compilation error (compiling during dependency injection)
2.2. Startup class not found
2.3. Multiple startup problems
2.4. Null pointer exception at runtime
2.5. Cannot find the corresponding Bean object
2.6. Dependency injection exception
2.7. Unit test test method definition
2.8. The definition of non-unique Bean is abnormal
3. Database connection problem in SpringBoot project
3.1. URL is not configured or configured incorrectly
3.2. Communication abnormal when establishing url connection
3.3. Rejected when accessing the database
4. MyBatis integration problem in SpringBoot project
4.1. SQL mapping not found
4.2. The attribute described by Autowired has an error message
4.3. BindingException BindingException
5. Web request problem in SpringBoot project
5.1. The service is not started successfully or the access port is wrong
5.2. Analysis of the problem of port occupied when the service starts
5.3. Request 404 problem and solution analysis
5.4. Thymeleaf template does not exist exception
5.5. JSON data conversion abnormal analysis
5.6. 400 request exception analysis
5.7. 405 Request exception analysis
6. Exceptions in Ajax
6.1 Concurrent update exception
6.2 No response after the event is triggered
6.3 Object property access problem
6.4 Cross-domain access issues
6.5 Access function does not exist
6.6 Callback function understanding problem
6.7 Request 415 exception problem
6.8 There is no problem with small icons
7. Bug in JS/JQuery/Ajax
7.1 Cannot receive ajax return value
//页面加载完成异步加载当前页数据
function doGetObjects() {
var id = getCurrentUserData();
console.log("当前用户id=" + id);
let url = `user/doFindUserInfo/${
id}`;
$.ajax({
url,
success(result) {
doHandleResponseResult(result);
}
});
}
function getCurrentUserData() {
var id ;
$.ajax({
url: "user/doFindCurrentUserId",
async: false,
success: function (result) {
id = result;
}
})
return id;
}
8. Problems in shiro
8.1 SecurityUtils.getSubject().getPrincipal()为null
Solution: Only the SecurityUtils.getSubject().getPrincipal() obtained under the User class and UserController/UserService is the user object. In other methods, the value is not available (null value), so a new one in SysUserServiceImpl HashMap encapsulates and returns object information, and then call this method from other locations!
@Override
public HashMap<String, Object> getCurrentUserData() {
SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
HashMap<String, Object> map = new HashMap<>();
map.put("id", user.getId());
map.put("username", user.getUsername());
map.put("password", user.getPassword());
map.put("salt", user.getSalt());
map.put("sex", user.getSex());
map.put("email", user.getEmail());
map.put("mobile", user.getMobile());
map.put("valid", user.getValid());
map.put("createdTime", user.getCreatedTime());
map.put("modifieTime", user.getModifiedTime());
map.put("createdUser", user.getCreatedUser());
map.put("birthday", user.getBirthday());
return map;
}
Then the other Service layer can call this method to realize the business
@Override
public int reserveSeat(SysSeat entity) {
HashMap<String, Object> userMap = sysUserService.getCurrentUserData();
entity.setUsedUser((String) userMap.get("username"));
entity.setState(2);
return sysSeatDao.reserveSeat(entity);
}
Appearance time: 2021/2/9 11:50 After the seat is successfully reserved in the library seat management system, the user name of the reserved user is displayed as the list