@@ -0,0 +1,1054 @@
+package com.github.origin.controller;%0A%0Aimport org.apache.log4j.Logger;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.cloud.client.ServiceInstance;%0Aimport org.springframework.cloud.client.discovery.DiscoveryClient;%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0Aimport org.springframework.web.bind.annotation.RequestMethod;%0Aimport org.springframework.web.bind.annotation.RequestParam;%0Aimport org.springframework.web.bind.annotation.RestController;%0A%0A%0A/**%0A * Created by Zhu on 2017/3/1.%0A */%0A@RestController%0Apublic class ComputeController %7B%0A%0A%09private final Logger logger = Logger.getLogger(getClass());%0A%0A%09@Autowired%0A%09private DiscoveryClient client;%0A%0A%09@RequestMapping(value = %22/add%22, method = RequestMethod.GET)%0A%09public Integer add(@RequestParam Integer a, @RequestParam Integer b)%7B%0A%09%09ServiceInstance instance = client.getLocalServiceInstance();%0A%09%09Integer r = a + b;%0A%09%09logger.info(%22/add, host:%22 + instance.getHost() + %22, service_id:%22 + instance.getServiceId() + %22, result:%22 + r);%0A%09%09return r;%0A%09%7D%0A%0A%0A%7D%0A

更新配置文件 添加注解