diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java index 7153f46..34b9059 100644 --- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java +++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java @@ -40,8 +40,8 @@ public class PositionConfig { PositionConfig() { - hello = configurableApplicationContext.getEnvironment().getProperty("position.hello"); - name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name"); + //hello = configurableApplicationContext.getEnvironment().getProperty("position.hello"); + //name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name"); } private static PositionConfig instance; diff --git a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java index 22cba9b..4783081 100644 --- a/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java +++ b/src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java @@ -7,6 +7,7 @@ import com.telpo.dipperposition.co.RzlAccount; import com.telpo.dipperposition.config.PositionConfig; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -27,8 +28,9 @@ import com.alibaba.nacos.api.config.listener.Listener; @RestController @Slf4j public class DipperPositionController { - - RzlAccount rzlAccount; + @Value(value = "${position.hello}") + private String hello; + //RzlAccount rzlAccount; @RequestMapping("/getPos") public String getPos() throws NacosException, InterruptedException, IOException { @@ -44,8 +46,7 @@ public class DipperPositionController { // //log.info(positionId + ":" + content.positionId) // Map dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml"); // return dataMap == null ? "" : (String)dataMap.get(positionId); - String returnStr= - "return position = " + PositionConfig.getInstance().getHello() + "return name = " + PositionConfig.getInstance().getName(); + String returnStr= "return position = " + hello; return returnStr; //return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();