From a0b9985df0d10b90199856f1d6283b5bed73571c Mon Sep 17 00:00:00 2001
From: zyx <1029606625@qq.com>
Date: Thu, 25 May 2023 16:27:45 +0800
Subject: [PATCH] 5/25 16:27
---
.idea/compiler.xml | 2 +
.idea/easyCodeTableSetting.xml | 44 +++++++++++++
.idea/encodings.xml | 2 +
.idea/misc.xml | 1 +
springboot525/pom.xml | 64 +++++++++++++++++++
.../src/main/java/cn/czyx007/Application.java | 15 +++++
.../src/main/java/cn/czyx007/bean/Person.java | 20 ++++++
.../src/main/java/cn/czyx007/bean/User.java | 36 +++++++++++
.../czyx007/controller/HelloController.java | 44 +++++++++++++
.../java/cn/czyx007/mapper/UserMapper.java | 13 ++++
.../java/cn/czyx007/service/UserService.java | 13 ++++
.../czyx007/service/impl/UserServiceImpl.java | 26 ++++++++
.../src/main/resources/application.yml | 15 +++++
.../src/main/resources/mappers/userMapper.xml | 11 ++++
.../java/cn/czyx007/ApplicationTests.java | 14 ++++
15 files changed, 320 insertions(+)
create mode 100644 springboot525/pom.xml
create mode 100644 springboot525/src/main/java/cn/czyx007/Application.java
create mode 100644 springboot525/src/main/java/cn/czyx007/bean/Person.java
create mode 100644 springboot525/src/main/java/cn/czyx007/bean/User.java
create mode 100644 springboot525/src/main/java/cn/czyx007/controller/HelloController.java
create mode 100644 springboot525/src/main/java/cn/czyx007/mapper/UserMapper.java
create mode 100644 springboot525/src/main/java/cn/czyx007/service/UserService.java
create mode 100644 springboot525/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java
create mode 100644 springboot525/src/main/resources/application.yml
create mode 100644 springboot525/src/main/resources/mappers/userMapper.xml
create mode 100644 springboot525/src/test/java/cn/czyx007/ApplicationTests.java
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index e4bf485..4b6a7e3 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -13,6 +13,7 @@
+
@@ -26,6 +27,7 @@
\ No newline at end of file
diff --git a/.idea/easyCodeTableSetting.xml b/.idea/easyCodeTableSetting.xml
index ae9b630..f264f8a 100644
--- a/.idea/easyCodeTableSetting.xml
+++ b/.idea/easyCodeTableSetting.xml
@@ -305,6 +305,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 3131fb6..60e00e0 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -23,6 +23,8 @@
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 85083a6..9b69f6c 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -24,6 +24,7 @@
+
diff --git a/springboot525/pom.xml b/springboot525/pom.xml
new file mode 100644
index 0000000..fb357b8
--- /dev/null
+++ b/springboot525/pom.xml
@@ -0,0 +1,64 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.7.12
+
+
+ com.example
+ springboot525
+ 0.0.1-SNAPSHOT
+ springboot525
+ springboot525
+
+ 11
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ 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
+ 2.2.2
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+
+
diff --git a/springboot525/src/main/java/cn/czyx007/Application.java b/springboot525/src/main/java/cn/czyx007/Application.java
new file mode 100644
index 0000000..1c3b635
--- /dev/null
+++ b/springboot525/src/main/java/cn/czyx007/Application.java
@@ -0,0 +1,15 @@
+package cn.czyx007;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@MapperScan("cn.czyx007.mapper")
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+}
diff --git a/springboot525/src/main/java/cn/czyx007/bean/Person.java b/springboot525/src/main/java/cn/czyx007/bean/Person.java
new file mode 100644
index 0000000..7b0da6a
--- /dev/null
+++ b/springboot525/src/main/java/cn/czyx007/bean/Person.java
@@ -0,0 +1,20 @@
+package cn.czyx007.bean;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author : 张宇轩
+ * @createTime : 2023/5/25 - 14:57
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "person")
+public class Person {
+ private String userName;
+ private String password;
+ private String address;
+ private Integer age;
+ private String email;
+}
diff --git a/springboot525/src/main/java/cn/czyx007/bean/User.java b/springboot525/src/main/java/cn/czyx007/bean/User.java
new file mode 100644
index 0000000..eb9b9cb
--- /dev/null
+++ b/springboot525/src/main/java/cn/czyx007/bean/User.java
@@ -0,0 +1,36 @@
+package cn.czyx007.bean;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * (User)实体类
+ *
+ * @author 张宇轩
+ * @since 2023-05-25 15:30:24
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class User implements Serializable {
+ private static final long serialVersionUID = 872728960100083467L;
+ /**
+ * 主键ID
+ */
+ private Long id;
+ /**
+ * 姓名
+ */
+ private String name;
+ /**
+ * 年龄
+ */
+ private Integer age;
+ /**
+ * 邮箱
+ */
+ private String email;
+}
diff --git a/springboot525/src/main/java/cn/czyx007/controller/HelloController.java b/springboot525/src/main/java/cn/czyx007/controller/HelloController.java
new file mode 100644
index 0000000..09bda0e
--- /dev/null
+++ b/springboot525/src/main/java/cn/czyx007/controller/HelloController.java
@@ -0,0 +1,44 @@
+package cn.czyx007.controller;
+
+import cn.czyx007.bean.Person;
+import cn.czyx007.bean.User;
+import cn.czyx007.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author : 张宇轩
+ * @createTime : 2023/5/25 - 14:55
+ */
+@RestController
+public class HelloController {
+ @Value("${person.username}")
+ private String userName;
+
+ @Autowired
+ private Person person;
+
+ @Autowired
+ private UserService userService;
+
+ @GetMapping("/getUser")
+ public List getUser(){
+ return userService.findUser();
+ }
+
+ @GetMapping("/good")
+ private String good(){
+ System.out.println("userName = " + userName);
+ return "good,springboot!!!";
+ }
+
+ @GetMapping("/person")
+ public String person(){
+ System.out.println("person = " + person);
+ return "person";
+ }
+}
diff --git a/springboot525/src/main/java/cn/czyx007/mapper/UserMapper.java b/springboot525/src/main/java/cn/czyx007/mapper/UserMapper.java
new file mode 100644
index 0000000..99a9901
--- /dev/null
+++ b/springboot525/src/main/java/cn/czyx007/mapper/UserMapper.java
@@ -0,0 +1,13 @@
+package cn.czyx007.mapper;
+
+import cn.czyx007.bean.User;
+
+import java.util.List;
+
+/**
+ * @author : 张宇轩
+ * @createTime : 2023/5/25 - 15:30
+ */
+public interface UserMapper {
+ List getUser();
+}
diff --git a/springboot525/src/main/java/cn/czyx007/service/UserService.java b/springboot525/src/main/java/cn/czyx007/service/UserService.java
new file mode 100644
index 0000000..ce2966a
--- /dev/null
+++ b/springboot525/src/main/java/cn/czyx007/service/UserService.java
@@ -0,0 +1,13 @@
+package cn.czyx007.service;
+
+import cn.czyx007.bean.User;
+
+import java.util.List;
+
+/**
+ * @author : 张宇轩
+ * @createTime : 2023/5/25 - 15:46
+ */
+public interface UserService {
+ List findUser();
+}
diff --git a/springboot525/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java b/springboot525/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..a756257
--- /dev/null
+++ b/springboot525/src/main/java/cn/czyx007/service/impl/UserServiceImpl.java
@@ -0,0 +1,26 @@
+package cn.czyx007.service.impl;
+
+import cn.czyx007.bean.User;
+import cn.czyx007.mapper.UserMapper;
+import cn.czyx007.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @author : 张宇轩
+ * @createTime : 2023/5/25 - 15:47
+ */
+@Service
+@Transactional
+public class UserServiceImpl implements UserService {
+ @Autowired(required = false)
+ private UserMapper userMapper;
+
+ @Override
+ public List findUser() {
+ return userMapper.getUser();
+ }
+}
diff --git a/springboot525/src/main/resources/application.yml b/springboot525/src/main/resources/application.yml
new file mode 100644
index 0000000..78b5110
--- /dev/null
+++ b/springboot525/src/main/resources/application.yml
@@ -0,0 +1,15 @@
+spring:
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/person_info?serverTimezone=Asia/Shanghai
+ username: root
+ password: zyx007
+
+mybatis:
+ type-aliases-package: cn.czyx007.bean
+ mapper-locations: classpath:mappers/*.xml
+ configuration:
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+person:
+ username: abc
diff --git a/springboot525/src/main/resources/mappers/userMapper.xml b/springboot525/src/main/resources/mappers/userMapper.xml
new file mode 100644
index 0000000..0eca6d8
--- /dev/null
+++ b/springboot525/src/main/resources/mappers/userMapper.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/springboot525/src/test/java/cn/czyx007/ApplicationTests.java b/springboot525/src/test/java/cn/czyx007/ApplicationTests.java
new file mode 100644
index 0000000..9968ed0
--- /dev/null
+++ b/springboot525/src/test/java/cn/czyx007/ApplicationTests.java
@@ -0,0 +1,14 @@
+package cn.czyx007;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class ApplicationTests {
+
+ @Test
+ void contextLoads() {
+
+ }
+
+}