4
4
import org .apache .http .client .methods .HttpGet ;
5
5
import org .apache .http .impl .client .CloseableHttpClient ;
6
6
import org .apache .http .impl .client .HttpClientBuilder ;
7
+ import org .springframework .beans .factory .annotation .Autowired ;
8
+ import org .springframework .beans .factory .annotation .Qualifier ;
7
9
import org .springframework .beans .factory .annotation .Value ;
8
10
import org .springframework .stereotype .Controller ;
9
11
import org .springframework .ui .Model ;
10
12
import org .springframework .web .bind .annotation .GetMapping ;
13
+ import org .springframework .web .bind .annotation .ResponseBody ;
14
+ import org .springframework .web .client .RestTemplate ;
11
15
12
16
import javax .annotation .PostConstruct ;
17
+ import javax .servlet .http .HttpServletRequest ;
13
18
import java .util .concurrent .Executors ;
14
19
import java .util .concurrent .ScheduledExecutorService ;
15
20
import java .util .concurrent .ThreadFactory ;
18
23
@ Controller
19
24
public class DemoController {
20
25
26
+ @ Autowired
27
+ @ Qualifier ("restTemplate" )
28
+ private RestTemplate restTemplate ;
21
29
22
30
@ Value ("${demo.qps:100}" )
23
31
private int qps ;
24
32
25
33
@ Value ("${enable.mq.invoke:false}" )
26
34
private boolean enableMqInvoke ;
27
35
28
-
29
36
@ Value ("${background.color:white}" )
30
37
private String backgroundColor ;
31
38
@@ -47,6 +54,13 @@ public String index(Model model) {
47
54
return "index" ;
48
55
}
49
56
57
+ @ GetMapping ("/spring_boot" )
58
+ @ ResponseBody
59
+ public String spring_boot (HttpServletRequest request ) {
60
+ String result = restTemplate .getForObject ("http://sc-a:20001/spring_boot" , String .class );
61
+ return result ;
62
+ }
63
+
50
64
@ PostConstruct
51
65
private void flow () {
52
66
if (qps > 0 ) {
0 commit comments