- package Solin.controller;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.core.env.Environment;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- @RestController
- public class WebController {
- @Autowired
- private Environment env;
-
- //test.msg就是配置键
- @RequestMapping("/index")
- public String index2(){
- return env.getProperty("test.msg");
- }
- }