diff --git a/src/main/java/com/telpo/dipperposition/co/RzlAccount.java b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java index d332dd6..709f4da 100644 --- a/src/main/java/com/telpo/dipperposition/co/RzlAccount.java +++ b/src/main/java/com/telpo/dipperposition/co/RzlAccount.java @@ -3,6 +3,7 @@ package com.telpo.dipperposition.co; import lombok.Getter; import lombok.Setter; import lombok.ToString; +import org.springframework.stereotype.Component; /** * @program: RzlAccount @@ -13,6 +14,7 @@ import lombok.ToString; @Getter @Setter @ToString +@Component public class RzlAccount { private String hello; diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java index 1202dc6..157fc25 100644 --- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java +++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java @@ -3,7 +3,9 @@ package com.telpo.dipperposition.controller; import com.alibaba.cloud.nacos.parser.NacosDataParserHandler; import com.alibaba.nacos.api.PropertyKeyConst; import com.alibaba.nacos.api.exception.NacosException; +import com.telpo.dipperposition.co.RzlAccount; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -25,20 +27,24 @@ import com.alibaba.nacos.api.config.listener.Listener; @Slf4j public class DipperPositionController { + @Autowired RzlAccount rzlAccount; + @RequestMapping("/getPos") public String getPos() throws NacosException, InterruptedException, IOException { - String group = "DEFAULT_GROUP"; - String dataId = "dipperposition-service"; - String positionId = "position.hello"; - Properties properties = new Properties(); - String serverAddr = "172.16.192.26"; - properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr); - ConfigService configService = NacosFactory.createConfigService(properties); - String content = configService.getConfig(dataId, group, 10000); - System.out.println(content); - //log.info(positionId + ":" + content.positionId) - Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml"); - return dataMap == null ? "" : (String)dataMap.get(positionId); +// String group = "DEFAULT_GROUP"; +// String dataId = "dipperposition-service"; +// String positionId = "position.hello"; +// Properties properties = new Properties(); +// String serverAddr = "172.16.192.26"; +// properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr); +// ConfigService configService = NacosFactory.createConfigService(properties); +// String content = configService.getConfig(dataId, group, 10000); +// System.out.println(content); +// //log.info(positionId + ":" + content.positionId) +// Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml"); +// return dataMap == null ? "" : (String)dataMap.get(positionId); + + return rzlAccount.getHello(); //return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString(); } }