From 00158d24921547daa598f4f92cb1d66d47268871 Mon Sep 17 00:00:00 2001 From: qinyingjie Date: Fri, 9 Dec 2022 15:56:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 72 ++++++++++++------ .../SpringBootKwanApplication.java | 2 - .../com/kwan/springbootkwan/entity/User.java | 22 ++++++ src/main/resources/application.yaml | 15 +++- src/main/resources/mapper/UserMapper.xml | 4 + .../SpringBootKwanApplicationTests.java | 13 ---- .../springbootkwan/UserServiceImplTest.java | 74 +++++++++++++++++++ 7 files changed, 163 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/kwan/springbootkwan/entity/User.java create mode 100644 src/main/resources/mapper/UserMapper.xml delete mode 100644 src/test/java/com/kwan/springbootkwan/SpringBootKwanApplicationTests.java create mode 100644 src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java diff --git a/pom.xml b/pom.xml index 07304c7..cdceb06 100644 --- a/pom.xml +++ b/pom.xml @@ -25,22 +25,9 @@ org.springframework.boot spring-boot-starter-web - - org.projectlombok - lombok - true - - - org.springframework.boot - spring-boot-starter-test - test - - - - mysql - mysql-connector-java - 8.0.21 - + + + @@ -49,13 +36,7 @@ 1.2.3 - - - junit - junit - 4.12 - test - + @@ -71,6 +52,51 @@ springfox-swagger-ui 2.9.2 + + + org.apache.velocity + velocity-engine-core + 2.0 + + + + org.apache.commons + commons-lang3 + 3.9 + + + + com.baomidou + mybatis-plus-boot-starter + 3.4.3.1 + + + + mysql + mysql-connector-java + runtime + + + + org.projectlombok + lombok + true + + + + org.springframework.boot + spring-boot-starter-test + test + + + junit + junit + 4.13.1 + test + + + + diff --git a/src/main/java/com/kwan/springbootkwan/SpringBootKwanApplication.java b/src/main/java/com/kwan/springbootkwan/SpringBootKwanApplication.java index 0413b35..d1f9ac8 100644 --- a/src/main/java/com/kwan/springbootkwan/SpringBootKwanApplication.java +++ b/src/main/java/com/kwan/springbootkwan/SpringBootKwanApplication.java @@ -1,9 +1,7 @@ package com.kwan.springbootkwan; - import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.scheduling.annotation.EnableScheduling; - @EnableScheduling @SpringBootApplication public class SpringBootKwanApplication { diff --git a/src/main/java/com/kwan/springbootkwan/entity/User.java b/src/main/java/com/kwan/springbootkwan/entity/User.java new file mode 100644 index 0000000..1bf24c6 --- /dev/null +++ b/src/main/java/com/kwan/springbootkwan/entity/User.java @@ -0,0 +1,22 @@ +package com.kwan.springbootkwan.entity; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +@Data +@Builder +@TableName(value = "User")//指定表名 +public class User implements Serializable { + private static final long serialVersionUID = -5644799954031156649L; + //value与数据库主键列名一致,若实体类属性名与表主键列名一致可省略value + @TableId(value = "id", type = IdType.AUTO)//指定自增策略 + private Integer id; + private String name; + private String sex; + private String pwd; + private String email; +} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 410a7ed..8d7b4fb 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -8,4 +8,17 @@ swagger: spring: mvc: pathmatch: - matching-strategy: ant_path_matcher \ No newline at end of file + matching-strategy: ant_path_matcher + profiles: + active: dev + # mysql + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai + username: root + password: 716288qwe +mybatis-plus: + mapper-locations: mapper/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + map-underscore-to-camel-case: true \ No newline at end of file diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..494132e --- /dev/null +++ b/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/test/java/com/kwan/springbootkwan/SpringBootKwanApplicationTests.java b/src/test/java/com/kwan/springbootkwan/SpringBootKwanApplicationTests.java deleted file mode 100644 index 7a68846..0000000 --- a/src/test/java/com/kwan/springbootkwan/SpringBootKwanApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.kwan.springbootkwan; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class SpringBootKwanApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java b/src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java new file mode 100644 index 0000000..557c610 --- /dev/null +++ b/src/test/java/com/kwan/springbootkwan/UserServiceImplTest.java @@ -0,0 +1,74 @@ +//package com.kwan.springbootkwan; +// +// +//import com.kwan.springbootkwan.entity.User; +//import com.kwan.springbootkwan.service.impl.UserServiceImpl; +//import org.junit.jupiter.api.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.test.context.SpringBootTest; +// +//import java.util.ArrayList; +//import java.util.List; +// +// +//@SpringBootTest +//public class UserServiceImplTest { +// +// @Autowired +// UserServiceImpl userService; +// @Test +// public void queryAll() { +// userService.queryAll().forEach(System.out::println); +// } +// +// @Test +// public void add() { +// List users = new ArrayList<>(); +// for (int i = 0; i < 15; ++i) { +// User user = User.builder().id(i + 1).name("test" + i).sex(i % 2 == 0 ? "男" : "女").pwd("aaaa").email("123" + i + "@qq.com").build(); +// +// users.add(user); +// } +// users.forEach(System.out::println); +// userService.add(users); +// +// +// } +// +// @Test +// public void query() { +// userService.queryAll().forEach(System.out::println); +// +// userService.queryByName1("test1").forEach(System.out::println); +// userService.queryByName2("test1").forEach(System.out::println); +// User user = userService.queryById(User.builder().id(2).build()); +// System.out.println(user); +// userService.queryByNameMap("test1").forEach(System.out::println); +// System.out.println(userService.count()); +// } +// +// @Test +// public void delete() { +// User user = User.builder().id(2).build(); +// userService.deleteById(user); +// +// userService.deleteBy("name", "test15"); +// +// userService.deleteByIds(); +// +// } +// +// @Test +// public void change() { +// User user1 = User.builder().name("蔡徐坤").build(); +// userService.changeBy(user1, "sex", "男"); +// +// user1.setName("蔡徐坤2"); +// userService.changeUserById(user1); +// } +// +//// public void test1(){ +//// userService.register() +//// } +// +//} -- GitLab