DemoController.java
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.springboot.template.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.springboot.template.redis.HelloRedis;
import com.springboot.template.service.JdbcService;
@Controller
@RequestMapping("/demo")
public class DemoController {
@Autowired
private JdbcService jdbcService;
@Autowired
private HelloRedis helloRedis;
@RequestMapping("/sayHello")
@ResponseBody
public String sayHello() {
return "hello";
}
@GetMapping("sayFromJdbc")
@ResponseBody
public String sayFromJdbc() {
return this.jdbcService.queryHello();
}
@GetMapping("sayFromJpa")
@ResponseBody
public String sayFromJpa() {
return this.jdbcService.queryHelloFromJpa();
}
@GetMapping("sayFromRedis")
@ResponseBody
public String sayFromRedis() {
return this.helloRedis.getName();
}
@GetMapping("sayFromLogback")
@ResponseBody
public String sayFromLogback() {
Logger log = LoggerFactory.getLogger(this.getClass());
log.debug("HERE WE ARE!");
return "wang bin logback";
}
}