From 19cc3148709b9c225fe778a642eab7c473cae26a Mon Sep 17 00:00:00 2001 From: xuxin <840198532@qq.com> Date: Sun, 18 Oct 2026 14:57:19 +0800 Subject: [PATCH] =?UTF-8?q?javaEEday09-mybatis-crud-=E5=87=86=E5=A4=87?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- springboot-mybatis-crud/.gitignore | 33 ++++++ .../.mvn/wrapper/maven-wrapper.properties | 3 + springboot-mybatis-crud/pom.xml | 107 ++++++++++++++++++ .../SpringbootMybatisCrudApplication.java | 13 +++ .../java/com/inmind/mapper/EmpMapper.java | 8 ++ .../src/main/java/com/inmind/pojo/Emp.java | 26 +++++ .../src/main/resources/application.properties | 6 + ...SpringbootMybatisCrudApplicationTests.java | 13 +++ 8 files changed, 209 insertions(+) create mode 100644 springboot-mybatis-crud/.gitignore create mode 100644 springboot-mybatis-crud/.mvn/wrapper/maven-wrapper.properties create mode 100644 springboot-mybatis-crud/pom.xml create mode 100644 springboot-mybatis-crud/src/main/java/com/inmind/SpringbootMybatisCrudApplication.java create mode 100644 springboot-mybatis-crud/src/main/java/com/inmind/mapper/EmpMapper.java create mode 100644 springboot-mybatis-crud/src/main/java/com/inmind/pojo/Emp.java create mode 100644 springboot-mybatis-crud/src/main/resources/application.properties create mode 100644 springboot-mybatis-crud/src/test/java/com/inmind/SpringbootMybatisCrudApplicationTests.java diff --git a/springboot-mybatis-crud/.gitignore b/springboot-mybatis-crud/.gitignore new file mode 100644 index 0000000..667aaef --- /dev/null +++ b/springboot-mybatis-crud/.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-mybatis-crud/.mvn/wrapper/maven-wrapper.properties b/springboot-mybatis-crud/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..bb58b3c --- /dev/null +++ b/springboot-mybatis-crud/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,3 @@ +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.0/apache-maven-3.10.0-bin.zip diff --git a/springboot-mybatis-crud/pom.xml b/springboot-mybatis-crud/pom.xml new file mode 100644 index 0000000..00b562c --- /dev/null +++ b/springboot-mybatis-crud/pom.xml @@ -0,0 +1,107 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.5.16 + + + com.inmind + springboot-mybatis-crud + 0.0.1-SNAPSHOT + springboot-mybatis-crud + springboot-mybatis-crud + + + + + + + + + + + + + + + 17 + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 3.0.5 + + + + com.mysql + mysql-connector-j + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.mybatis.spring.boot + mybatis-spring-boot-starter-test + 3.0.5 + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + compile + + compile + + + + + org.projectlombok + lombok + + + + + + default-testCompile + test-compile + + testCompile + + + + + org.projectlombok + lombok + + + + + + + + + + diff --git a/springboot-mybatis-crud/src/main/java/com/inmind/SpringbootMybatisCrudApplication.java b/springboot-mybatis-crud/src/main/java/com/inmind/SpringbootMybatisCrudApplication.java new file mode 100644 index 0000000..65b715c --- /dev/null +++ b/springboot-mybatis-crud/src/main/java/com/inmind/SpringbootMybatisCrudApplication.java @@ -0,0 +1,13 @@ +package com.inmind; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringbootMybatisCrudApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringbootMybatisCrudApplication.class, args); + } + +} diff --git a/springboot-mybatis-crud/src/main/java/com/inmind/mapper/EmpMapper.java b/springboot-mybatis-crud/src/main/java/com/inmind/mapper/EmpMapper.java new file mode 100644 index 0000000..7fbd97c --- /dev/null +++ b/springboot-mybatis-crud/src/main/java/com/inmind/mapper/EmpMapper.java @@ -0,0 +1,8 @@ +package com.inmind.mapper; + +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface EmpMapper { + //定义方法 +} diff --git a/springboot-mybatis-crud/src/main/java/com/inmind/pojo/Emp.java b/springboot-mybatis-crud/src/main/java/com/inmind/pojo/Emp.java new file mode 100644 index 0000000..5f206a4 --- /dev/null +++ b/springboot-mybatis-crud/src/main/java/com/inmind/pojo/Emp.java @@ -0,0 +1,26 @@ +package com.inmind.pojo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Emp { + private Integer id;//id + private String username;//用户名 + private String password;//密码 + private String name;//姓名 + private Short gender;//性别:1:男 2:女 + private String image;//图像 + private Short job;//职位 + private LocalDate entrydate;//入职日期 + private Integer deptId;//部门编号 + private LocalDateTime createTime;//创建时间 + private LocalDateTime updateTime;//更新时间 + +} diff --git a/springboot-mybatis-crud/src/main/resources/application.properties b/springboot-mybatis-crud/src/main/resources/application.properties new file mode 100644 index 0000000..c92c824 --- /dev/null +++ b/springboot-mybatis-crud/src/main/resources/application.properties @@ -0,0 +1,6 @@ +spring.application.name=springboot-mybatis-crud +#spring.datasource.type= com.alibaba.druid.pool.DruidDataSource +spring.datasource.url= jdbc:mysql://localhost:3306/mybatis +spring.datasource.username= root +spring.datasource.password= 1234 +spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driver \ No newline at end of file diff --git a/springboot-mybatis-crud/src/test/java/com/inmind/SpringbootMybatisCrudApplicationTests.java b/springboot-mybatis-crud/src/test/java/com/inmind/SpringbootMybatisCrudApplicationTests.java new file mode 100644 index 0000000..f8cf9fe --- /dev/null +++ b/springboot-mybatis-crud/src/test/java/com/inmind/SpringbootMybatisCrudApplicationTests.java @@ -0,0 +1,13 @@ +package com.inmind; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SpringbootMybatisCrudApplicationTests { + + @Test + void contextLoads() { + } + +}