OrderController.java 1.1 KB
Newer Older
M
ManongJu 已提交
1
package com.microservice.skeleton.order.controller;
M
ManongJu 已提交
2

M
ManongJu 已提交
3 4
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
M
ManongJu 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Mr.Yangxiufeng on 2017/12/9.
 * Time:16:44
 * ProjectName:Mirco-Service-Skeleton
 */
@RestController
M
ManongJu 已提交
18
public class OrderController {
M
ManongJu 已提交
19

M
ManongJu 已提交
20
    private static final Logger LOGGER = LoggerFactory.getLogger(OrderController.class);
M
ManongJu 已提交
21

M
ManongJu 已提交
22 23 24 25 26
    @Autowired
    private DiscoveryClient client;
    @RequestMapping(value = "/hello",method = RequestMethod.GET)
    public String index(){
        ServiceInstance instance = client.getLocalServiceInstance();
M
ManongJu 已提交
27
        LOGGER.info("here....................");
M
ManongJu 已提交
28
        return "Hello World : "+ instance.getServiceId()+",port:" + instance.getPort();
M
ManongJu 已提交
29 30 31
    }

}