This commit is contained in:
2023-03-09 21:56:34 +08:00
parent 50bd645ec5
commit 93689dc7d0
20 changed files with 319 additions and 8 deletions

View File

@@ -0,0 +1,16 @@
package com.yv;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author YoVinchen
*/
@SpringBootApplication
public class Springboot05MybatisApplication {
public static void main(String[] args) {
SpringApplication.run(Springboot05MybatisApplication.class, args);
}
}

View File

@@ -0,0 +1,19 @@
package com.yv.dao;
import com.yv.domain.Book;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
/**
* @author YoVinchen
* @date 2023/3/9 下午 3:25
*/
@Mapper
public interface BookDao {
/**
* @param id
* @return
*/
@Select("select * from tbl_book where id = #{id}")
public Book getById(Integer id);
}

View File

@@ -0,0 +1,55 @@
package com.yv.domain;
/**
* @author YoVinchen
* @date 2023/3/9 下午 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;
}
}

View File

@@ -0,0 +1,8 @@
#??????
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ssm_db?useSSL=false
username: root
password: 8520

View File

@@ -0,0 +1,19 @@
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 Springboot05MybatisApplicationTests {
@Autowired
private BookDao bookDao;
@Test
void contextLoads() {
System.out.println(bookDao.getById(1));
}
}