瀏覽代碼

增加配置文件读取

tags/v1.0.0^2
林万龙 3 年之前
父節點
當前提交
6f91bc025a
共有 2 個文件被更改,包括 7 次插入3 次删除
  1. +4
    -2
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java
  2. +3
    -1
      src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java

+ 4
- 2
src/main/java/com/telpo/dipperposition/config/PositionConfig.java 查看文件

@@ -27,11 +27,13 @@ import java.util.Properties;
@Setter
@ToString
@Configuration
@ConfigurationProperties(prefix = "position")
public class PositionConfig {
@Value("${position.hello}")
@Value(value = "${position.hello}")
private String hello;

@Value(value = "${spring.application.name}")
private String name;

PositionConfig()
{
}


+ 3
- 1
src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java 查看文件

@@ -44,7 +44,9 @@ public class DipperPositionController {
// //log.info(positionId + ":" + content.positionId)
// Map<String, Object> dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml");
// return dataMap == null ? "" : (String)dataMap.get(positionId);
return PositionConfig.getInstance().getHello();
String returnStr=
"return position = " + PositionConfig.getInstance().getHello() + "return name = " + PositionConfig.getInstance().getName();
return returnStr;
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString();
}
}

Loading…
取消
儲存