修改代码中的错误package com.zxq; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.zxq.domain.User; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import java.util.HashMap; import java.util.List; import java.util.Map; @SpringBootTest class SpringbootMybatisplusZbApplicationTests { @Test void contextLoads() { } public void selectByName(){ Map<String,Object> columnMap=new HashMap<>(); columnMap.put("name","admin"); List<User> list=userMapper.selectByMap(columnMap) } @Test public void selectByProperty(){ QueryWrapper<User> queryWrapper=new QueryWrapper<>(); // queryWrapper.like("name","a"); queryWrapper.select("name","sex");//投影查询 List<User> list=uerMapper.selectList(queryWrapper); System.out.println(list); } }
时间: 2024-01-11 20:05:55 浏览: 132
基于智能温度监测系统设计.doc
在代码中,缺少了一个分号,导致出现了语法错误。在selectByName()方法中,将最后一行代码中的分号添加上即可,修改后的代码如下:
```
package com.zxq;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zxq.domain.User;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@SpringBootTest
class SpringbootMybatisplusZbApplicationTests {
@Test
void contextLoads() {
}
public void selectByName(){
Map<String,Object> columnMap=new HashMap<>();
columnMap.put("name","admin");
List<User> list=userMapper.selectByMap(columnMap);
}
@Test
public void selectByProperty(){
QueryWrapper<User> queryWrapper=new QueryWrapper<>();
// queryWrapper.like("name","a");
queryWrapper.select("name","sex");//投影查询
List<User> list=userMapper.selectList(queryWrapper);
System.out.println(list);
}
}
```
阅读全文