From 93689dc7d042b40db572f3ee9be4468b25cd4107 Mon Sep 17 00:00:00 2001
From: Yo Vinchen <2982554722@qq.com>
Date: Thu, 9 Mar 2023 21:56:34 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/compiler.xml | 3 +
.idea/encodings.xml | 1 +
.../Maven__com_zaxxer_HikariCP_5_0_1.xml | 13 +++++
.../Maven__org_mybatis_mybatis_3_5_11.xml | 13 +++++
...aven__org_mybatis_mybatis_spring_3_0_0.xml | 13 +++++
...ybatis_spring_boot_autoconfigure_3_0_0.xml | 13 +++++
...boot_mybatis_spring_boot_starter_3_0_0.xml | 13 +++++
...rk_boot_spring_boot_starter_jdbc_3_0_4.xml | 13 +++++
..._org_springframework_spring_jdbc_6_0_6.xml | 13 +++++
...n__org_springframework_spring_tx_6_0_6.xml | 13 +++++
.idea/misc.xml | 1 +
.idea/modules.xml | 1 +
.../yv/Springboot04JunitApplicationTests.java | 20 ++++---
springboot_05_mybatis/.gitignore | 33 +++++++++++
springboot_05_mybatis/pom.xml | 47 ++++++++++++++++
.../yv/Springboot05MybatisApplication.java | 16 ++++++
.../src/main/java/com/yv/dao/BookDao.java | 19 +++++++
.../src/main/java/com/yv/domain/Book.java | 55 +++++++++++++++++++
.../src/main/resources/application.yml | 8 +++
.../Springboot05MybatisApplicationTests.java | 19 +++++++
20 files changed, 319 insertions(+), 8 deletions(-)
create mode 100644 .idea/libraries/Maven__com_zaxxer_HikariCP_5_0_1.xml
create mode 100644 .idea/libraries/Maven__org_mybatis_mybatis_3_5_11.xml
create mode 100644 .idea/libraries/Maven__org_mybatis_mybatis_spring_3_0_0.xml
create mode 100644 .idea/libraries/Maven__org_mybatis_spring_boot_mybatis_spring_boot_autoconfigure_3_0_0.xml
create mode 100644 .idea/libraries/Maven__org_mybatis_spring_boot_mybatis_spring_boot_starter_3_0_0.xml
create mode 100644 .idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_3_0_4.xml
create mode 100644 .idea/libraries/Maven__org_springframework_spring_jdbc_6_0_6.xml
create mode 100644 .idea/libraries/Maven__org_springframework_spring_tx_6_0_6.xml
create mode 100644 springboot_05_mybatis/.gitignore
create mode 100644 springboot_05_mybatis/pom.xml
create mode 100644 springboot_05_mybatis/src/main/java/com/yv/Springboot05MybatisApplication.java
create mode 100644 springboot_05_mybatis/src/main/java/com/yv/dao/BookDao.java
create mode 100644 springboot_05_mybatis/src/main/java/com/yv/domain/Book.java
create mode 100644 springboot_05_mybatis/src/main/resources/application.yml
create mode 100644 springboot_05_mybatis/src/test/java/com/yv/Springboot05MybatisApplicationTests.java
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 8a46d6f..1ba6028 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -11,6 +11,7 @@
+
@@ -25,6 +26,7 @@
+
@@ -37,6 +39,7 @@
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 3d3ce41..d272e11 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -15,5 +15,6 @@
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_zaxxer_HikariCP_5_0_1.xml b/.idea/libraries/Maven__com_zaxxer_HikariCP_5_0_1.xml
new file mode 100644
index 0000000..580a0e1
--- /dev/null
+++ b/.idea/libraries/Maven__com_zaxxer_HikariCP_5_0_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mybatis_mybatis_3_5_11.xml b/.idea/libraries/Maven__org_mybatis_mybatis_3_5_11.xml
new file mode 100644
index 0000000..35896ab
--- /dev/null
+++ b/.idea/libraries/Maven__org_mybatis_mybatis_3_5_11.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mybatis_mybatis_spring_3_0_0.xml b/.idea/libraries/Maven__org_mybatis_mybatis_spring_3_0_0.xml
new file mode 100644
index 0000000..fa851ca
--- /dev/null
+++ b/.idea/libraries/Maven__org_mybatis_mybatis_spring_3_0_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mybatis_spring_boot_mybatis_spring_boot_autoconfigure_3_0_0.xml b/.idea/libraries/Maven__org_mybatis_spring_boot_mybatis_spring_boot_autoconfigure_3_0_0.xml
new file mode 100644
index 0000000..5505d8a
--- /dev/null
+++ b/.idea/libraries/Maven__org_mybatis_spring_boot_mybatis_spring_boot_autoconfigure_3_0_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mybatis_spring_boot_mybatis_spring_boot_starter_3_0_0.xml b/.idea/libraries/Maven__org_mybatis_spring_boot_mybatis_spring_boot_starter_3_0_0.xml
new file mode 100644
index 0000000..6e05b54
--- /dev/null
+++ b/.idea/libraries/Maven__org_mybatis_spring_boot_mybatis_spring_boot_starter_3_0_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_3_0_4.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_3_0_4.xml
new file mode 100644
index 0000000..7ced8db
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_3_0_4.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_jdbc_6_0_6.xml b/.idea/libraries/Maven__org_springframework_spring_jdbc_6_0_6.xml
new file mode 100644
index 0000000..7065104
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_jdbc_6_0_6.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_tx_6_0_6.xml b/.idea/libraries/Maven__org_springframework_spring_tx_6_0_6.xml
new file mode 100644
index 0000000..5b493bf
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_tx_6_0_6.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index d251d83..d7a557d 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -24,6 +24,7 @@
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 54eb342..e375180 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -10,6 +10,7 @@
+
\ No newline at end of file
diff --git a/springboot_04_junit/src/test/java/com/yv/Springboot04JunitApplicationTests.java b/springboot_04_junit/src/test/java/com/yv/Springboot04JunitApplicationTests.java
index fa190d0..20ccb29 100644
--- a/springboot_04_junit/src/test/java/com/yv/Springboot04JunitApplicationTests.java
+++ b/springboot_04_junit/src/test/java/com/yv/Springboot04JunitApplicationTests.java
@@ -5,17 +5,21 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
+/**
+ * @RunWith(设置运行器)
+ * @ContextConfiguration(classes)
+ */
@SpringBootTest
class Springboot04JunitApplicationTests {
- //1.注入你要测试的对象
- @Autowired
- private BookDao bookDao;
+ //1.注入你要测试的对象
+ @Autowired
+ private BookDao bookDao;
- @Test
- void contextLoads() {
- //2.执行要测试的对象对应的方法
- bookDao.save();
- }
+ @Test
+ void contextLoads() {
+ //2.执行要测试的对象对应的方法
+ bookDao.save();
+ }
}
diff --git a/springboot_05_mybatis/.gitignore b/springboot_05_mybatis/.gitignore
new file mode 100644
index 0000000..549e00a
--- /dev/null
+++ b/springboot_05_mybatis/.gitignore
@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
diff --git a/springboot_05_mybatis/pom.xml b/springboot_05_mybatis/pom.xml
new file mode 100644
index 0000000..7124bb8
--- /dev/null
+++ b/springboot_05_mybatis/pom.xml
@@ -0,0 +1,47 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.0.4
+
+
+ com.yv
+ springboot_05_mybatis
+ 0.0.1-SNAPSHOT
+ springboot_05_mybatis
+ Demo project for Spring Boot
+
+ 17
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 3.0.0
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.49
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/springboot_05_mybatis/src/main/java/com/yv/Springboot05MybatisApplication.java b/springboot_05_mybatis/src/main/java/com/yv/Springboot05MybatisApplication.java
new file mode 100644
index 0000000..3868100
--- /dev/null
+++ b/springboot_05_mybatis/src/main/java/com/yv/Springboot05MybatisApplication.java
@@ -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);
+ }
+
+}
diff --git a/springboot_05_mybatis/src/main/java/com/yv/dao/BookDao.java b/springboot_05_mybatis/src/main/java/com/yv/dao/BookDao.java
new file mode 100644
index 0000000..d26ad81
--- /dev/null
+++ b/springboot_05_mybatis/src/main/java/com/yv/dao/BookDao.java
@@ -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);
+}
diff --git a/springboot_05_mybatis/src/main/java/com/yv/domain/Book.java b/springboot_05_mybatis/src/main/java/com/yv/domain/Book.java
new file mode 100644
index 0000000..0076133
--- /dev/null
+++ b/springboot_05_mybatis/src/main/java/com/yv/domain/Book.java
@@ -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;
+ }
+}
diff --git a/springboot_05_mybatis/src/main/resources/application.yml b/springboot_05_mybatis/src/main/resources/application.yml
new file mode 100644
index 0000000..9561a5f
--- /dev/null
+++ b/springboot_05_mybatis/src/main/resources/application.yml
@@ -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
diff --git a/springboot_05_mybatis/src/test/java/com/yv/Springboot05MybatisApplicationTests.java b/springboot_05_mybatis/src/test/java/com/yv/Springboot05MybatisApplicationTests.java
new file mode 100644
index 0000000..605de2e
--- /dev/null
+++ b/springboot_05_mybatis/src/test/java/com/yv/Springboot05MybatisApplicationTests.java
@@ -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));
+ }
+
+}