Browse Source

增加配置文件读取

tags/v1.0.0^2
林万龙 3 years ago
parent
commit
205257eb1e
2 changed files with 4 additions and 3 deletions
  1. +2
    -2
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java
  2. +2
    -1
      src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java

+ 2
- 2
src/main/java/com/telpo/dipperposition/config/PositionConfig.java View File

@@ -16,11 +16,11 @@ import org.springframework.context.annotation.Configuration;
@Getter
@Setter
@ToString
@ConfigurationProperties("position")
@Configuration
@ConfigurationProperties(prefix = "position")
public class PositionConfig {

@Value("${hello}")
//@Value("${hello}")
private String hello;

}

+ 2
- 1
src/main/java/com/telpo/dipperposition/controller/DipperPositionController.java View File

@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.ContextLoader;

import java.time.Duration;
import java.time.LocalDateTime;
@@ -25,6 +26,6 @@ public class DipperPositionController {

@RequestMapping("/getPos")
public String getPos() {
return "Helle world!";
return "Helle world!" + ContextLoader.getCurrentWebApplicationContext().toString();
}
}

Loading…
Cancel
Save