springboot的application.properties配置文件的配置项读取
2018-03-16 16:44
981 查看
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");
}
}
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");
}
}
相关文章推荐
- Spring-boot中读取核心配置文件application和自定义properties配置文件的方式
- SpringBoot内部配置:“application.properties配置”和”使用XML配置”,读取属性文件中的内容,日志配置,Profile配置(学习:SpringBoot实战)
- springboot如何读取配置文件中的参数(例如:application-consts.properties) 又结合maven读取配置文件的顺序
- SpringBoot 配置文件 application.properties
- Spring Boot的properties配置文件读取
- SpringBoot 配置文件 application.properties(二)
- spring boot 读取配置文件(application.yml)中的属性值
- SpringBoot属性文件配置(application.properties/yml)
- springboot 修改默认加载的配置文件不为application.properties
- springboot中配置文件application.properties的理解
- spring boot 单元测试与读取配置文件(application.yml)中的属性值
- spring boot 读取配置文件(application.yml)中的属性值
- Spring Boot为我们准备了最佳的数据库连接池方案,只需要在属性文件(例如application.properties)中配置需要的连接池参数即可。
- 【springboot】Spring boot配置文件 application.properties
- spring boot 读取配置文件(application.yml)中的属性值
- spring-boot读取application配置文件中字段
- 如何将spring boot application.properties修改成为spring boot配置文件
- spring boot 动态切换application-xx.properties配置文件
- spring boot 读取配置文件(application.yml)中的属性值
- Spring Boot的properties配置文件读取