Browse Source

import lombok

zhangxiaoyu 3 years ago
parent
commit
48f52c34db

+ 14 - 5
src/main/java/com/example/springbootdemo/controller/TrainJavaController.java

@@ -2,6 +2,7 @@ package com.example.springbootdemo.controller;
2 2
 
3 3
 import com.example.springbootdemo.zxyTeST.sql.dao.FootScanCommonRepository;
4 4
 import com.example.springbootdemo.zxyTeST.sql.entity.FootScanCommonEntity;
5
+import com.example.springbootdemo.zxyTeST.ymlConfig.SemsxUser;
5 6
 import org.springframework.beans.factory.annotation.Autowired;
6 7
 import org.springframework.web.bind.annotation.*;
7 8
 
@@ -12,16 +13,24 @@ import java.util.Map;
12 13
 public class TrainJavaController {
13 14
     @Autowired
14 15
     FootScanCommonRepository footScanCommonRepository;
16
+    @Autowired
17
+    SemsxUser semsxUser;
15 18
     @RequestMapping("/footScan")
16 19
     public String getFootScanInfo() {
17 20
         FootScanCommonEntity  footScanCommonInfo = footScanCommonRepository.findByFootScanId(14815);
18 21
         return  footScanCommonInfo.getFootScanSign();
19 22
     }
20
-    @PostMapping("/postTest")
21
-    public List<FootScanCommonEntity> getFootScanList(@RequestParam Map<Integer,Object> params) {
22
-        return footScanCommonRepository.findByFootScanCommonId(2241);
23
+    @RequestMapping("/postTest")
24
+    public void getFootScanList(@RequestParam Map<Integer,Object> params) {
25
+        List<FootScanCommonEntity> a =  footScanCommonRepository.findByFootScanCommonId(2242);
26
+        for(FootScanCommonEntity b:a) {
27
+            System.out.println(b.getFootScanId());
28
+        }
29
+    }
30
+    @RequestMapping("/ymlTest")
31
+    public SemsxUser ymlTest() {
32
+        System.out.println(semsxUser.getUserName());
33
+        return  semsxUser;
23 34
     }
24
-
25
-
26 35
 
27 36
 }

+ 1 - 1
src/main/java/com/example/springbootdemo/zxyTeST/getProperties.java

@@ -4,7 +4,7 @@ import com.example.springbootdemo.zxyTeST.Enum.SystemType;
4 4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
5 5
 
6 6
 
7
-@SpringBootApplication
7
+//@SpringBootApplication
8 8
 public class getProperties {
9 9
     public static void main(String[] args){
10 10
 

+ 24 - 0
src/main/java/com/example/springbootdemo/zxyTeST/ymlConfig/SemsxUser.java

@@ -0,0 +1,24 @@
1
+package com.example.springbootdemo.zxyTeST.ymlConfig;
2
+
3
+import lombok.Data;
4
+import org.springframework.boot.context.properties.ConfigurationProperties;
5
+import org.springframework.stereotype.Component;
6
+
7
+import java.util.Date;
8
+import java.util.List;
9
+
10
+/**
11
+ * @author zhangxiaoyu
12
+ * @version 1.0
13
+ * @date 2021/5/28 上午9:20
14
+ */
15
+@ConfigurationProperties(prefix = "semsx")
16
+@Component
17
+@Data
18
+public class SemsxUser {
19
+    private String userName;
20
+    private Integer age;
21
+    private Date birth;
22
+    private String[] arrayString;
23
+    private List<String> listString;
24
+}

+ 22 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,22 @@
1
+semsx :
2
+  userName: zhangxiaoyu
3
+  age: 25
4
+  birth: 2019/12/19
5
+  arrayString: [zz,zzz,zzz0z]
6
+  listString:
7
+    - 4
8
+    - 5
9
+    - 6
10
+server:
11
+  port: 8082
12
+spring:
13
+  datasource:
14
+    url: jdbc:mysql://192.168.2.130:3306/ceshi?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
15
+    username: root
16
+    password: 123456
17
+    driver-class-name: com.mysql.cj.jdbc.Driver
18
+  jpa:
19
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
20
+    open-in-view: false
21
+  freemarker:
22
+    cache: false

+ 21 - 0
src/main/resources/application.yml

@@ -0,0 +1,21 @@
1
+semsx :
2
+  userName: "zhangxiaoyu /n zhangsanlisi"
3
+  age: 25
4
+  birth: 2019/12/19
5
+  arrayString: [zz,zzz,zzz111z]
6
+  listString:
7
+    - 4
8
+    - 5
9
+    - 6
10
+server:
11
+  port: 8081
12
+spring:
13
+  datasource:
14
+    url: jdbc:mysql://192.168.2.130:3306/ceshi?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
15
+    username: root
16
+    password: 123456
17
+    driver-class-name: com.mysql.cj.jdbc.Driver
18
+  jpa:
19
+    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
20
+    open-in-view: false
21
+