- 博客(6)
- 收藏
- 关注
原创 JAVA普通类或者工具类调用Service层或者Mapper层报空指针
一、使用示例代码如下(示例):@Componentpublic class XXXTest{ @Autowired private XXXService xxxService; @Autowired private XXXMapper xxxMapper; public XXXTest(){} public static XXXTest xxxTest; @PostConstruct public void init(){ xxxTest
2021-11-30 14:30:44 5015 4
原创 验证数据是否存在,别再使用count了
学习目标:验证数据是否存在,写法优化常见写法:目前比较常见的写法// SQL写法select count(*) from table where A = 1 and B = 2// java写法int num = xxDao.XXXCount(params);if(num > 0){ // 存在执行这里代码}else{ // 不存在执行这里代码}优化写法:优化后的写法// SQL写法select 1 from table where A = 1 AND B =
2021-10-29 16:38:32 237
原创 String类型字符串截取
一、字符串从前往后截取1.从前往后截取遇到某个字符截止String str = "我爱你_JAVA";String s = str.substring(0,str.indexOf("_"));System.out.println(s);我爱你二、字符串从后往前截取1. 从后往前截取遇到某个字符截止String str = "测试Excel_往前截取.xlsx";String substring = str.substring(str.lastIndexOf("_") + 1);Sys
2021-10-25 15:07:14 1846
原创 @RequestBody和@RequestParam 同时在方法体里面,使用postman传递参数报错
问题描述:提示:如果同时存在 @RequestBody和@RequestParam 的方法接收参数,数据传输过程中出现数据传输格式错误@PostMapping("/test")public void test(@RequestBody Test test,@RequestParam Long id) {}原因分析:解决方案@RequestBody如果实体属性不是必传参数,这个里面可以不填参数但是必须要有{},传递的json格式@RequestParam 传递参数的格式两种
2020-11-27 16:44:34 2020
原创 在使用node tools/initdb.js初始化数据库的时候报错
Previously, at most one TIMESTAMP column per table could be automatically initialized or updated to the current date and time. This restriction has been lifted. Any TIMESTAMP column definition can have any combination of DEFAULT CURRENT_TIMESTAMP and ON U
2020-04-16 16:16:02 508 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人