mybatisplus

官网啥都有

https://baomidou.com/

1.引入依赖

 <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>3.5.3.1</version>
</dependency>

2.定义Mapper

自定义的mapper继承MybatiesPlus提供的BaseMapper接口

public interface HotelMapper extends BaseMapper<Hotel> {
}

3.在 Spring Boot 启动类中添加 @MapperScan 注解,扫描 Mapper 文件夹

@MapperScan("com.zbc.mapper")
@SpringBootApplication
public class ElasticApplication {
    public static void main(String[] args) {
        SpringApplication.run(ElasticApplication.class, args);
    }
}

4.测试

@SpringBootTest(classes = ElasticApplication.class)
@RunWith(SpringRunner.class)
public class TestElasticSearch {
    @Autowired
    private HotelMapper hotelMapper;
    @Test
    public void testGetDoc(){
        Hotel hotel = hotelMapper.selectById("36934");
        System.out.println(hotel.toString());

    }
}

 

posted @ 2024-04-17 11:10  张碧晨  阅读(33)  评论(0)    收藏  举报