diff --git a/pom.xml b/pom.xml index 07304c78ee215d0ddb932747d563af752cddcf8b..cdceb06ef619e32bfdcd7c38fdabfbc260a70097 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 0413b3592bf3bc2349229b0fe6b847b002c9ce8e..d1f9ac896cc3194d06f5a6a954bfc904a8f60be4 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 0000000000000000000000000000000000000000..1bf24c6e3642b8060e9871186be99b3e8ec87386 --- /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 410a7ed92e32515edd287e6b9c1248e238d6a571..8d7b4fb09ff40a04e0ba4e64b25082e2d9fb94ea 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 0000000000000000000000000000000000000000..494132e94d37fd664e68fb2920b4e5799965493b --- /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 7a68846621eee984e1711752c2ed68d2d61515e5..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..557c6106498e9b32509c70fe24d1ea0f5f676a7e --- /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() +//// } +// +//}