Initial commit
This commit is contained in:
		@@ -0,0 +1,16 @@
 | 
			
		||||
package com.yv;
 | 
			
		||||
 | 
			
		||||
import org.springframework.boot.SpringApplication;
 | 
			
		||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author YoVinchen
 | 
			
		||||
 */
 | 
			
		||||
@SpringBootApplication
 | 
			
		||||
public class Springboot06MybatisPlusApplication {
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        SpringApplication.run(Springboot06MybatisPlusApplication.class, args);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,13 @@
 | 
			
		||||
package com.yv.dao;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 | 
			
		||||
import com.yv.domain.Book;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author YoVinchen
 | 
			
		||||
 * @date 2023/3/14 下午 3:25
 | 
			
		||||
 */
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface BookDao extends BaseMapper<Book> {
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,55 @@
 | 
			
		||||
package com.yv.domain;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author YoVinchen
 | 
			
		||||
 * @date 2023/3/14 下午 3:23
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class Book {
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private String  type;
 | 
			
		||||
    private String  name;
 | 
			
		||||
    private String  description;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Book{" +
 | 
			
		||||
                "id=" + id +
 | 
			
		||||
                ", type='" + type + '\'' +
 | 
			
		||||
                ", name='" + name + '\'' +
 | 
			
		||||
                ", description='" + description + '\'' +
 | 
			
		||||
                '}';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setId(Integer id) {
 | 
			
		||||
        this.id = id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getType() {
 | 
			
		||||
        return type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setType(String type) {
 | 
			
		||||
        this.type = type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setName(String name) {
 | 
			
		||||
        this.name = name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getDescription() {
 | 
			
		||||
        return description;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setDescription(String description) {
 | 
			
		||||
        this.description = description;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,13 @@
 | 
			
		||||
# 配置相关配置
 | 
			
		||||
spring:
 | 
			
		||||
  datasource:
 | 
			
		||||
    driver-class-name: com.mysql.jdbc.Driver
 | 
			
		||||
    url: jdbc:mysql://localhost:3306/ssm_db?useSSL=false
 | 
			
		||||
    username: root
 | 
			
		||||
    password: 8520
 | 
			
		||||
 | 
			
		||||
#配置Mp相关配置
 | 
			
		||||
mybatis-plus:
 | 
			
		||||
  global-config:
 | 
			
		||||
    db-config:
 | 
			
		||||
      table-prefix: tbl_
 | 
			
		||||
@@ -0,0 +1,23 @@
 | 
			
		||||
package com.yv;
 | 
			
		||||
 | 
			
		||||
import com.yv.dao.BookDao;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.boot.test.context.SpringBootTest;
 | 
			
		||||
 | 
			
		||||
@SpringBootTest
 | 
			
		||||
class Springboot06MybatisPlusApplicationTests {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private BookDao bookDao;
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    void contextLoads() {
 | 
			
		||||
		System.out.println(bookDao.selectById(1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    void testGetAll(){
 | 
			
		||||
        System.out.println(bookDao.selectList(null));
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user