【spring Boot】spring boot1.5以上版本@ConfigurationProperties取消location注解后的替代方案
2017-10-11 17:23
609 查看
前言
===========================================
初步接触Spring Boot
===========================================
资源文件中自定义属性值,配置在一个对象bean上,然后在程序中可以使用bean的属性值。
一。
View Code
四。
运行结果:
===========================================
初步接触Spring Boot
===========================================
资源文件中自定义属性值,配置在一个对象bean上,然后在程序中可以使用bean的属性值。
一。
package com.sxd.firstdemo; import com.sxd.beans.ConfigBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @SpringBootApplication @EnableConfigurationProperties(ConfigBean.class) public class FirstdemoApplication { @Autowired ConfigBean configBean; @RequestMapping("/") public String index(){ return "Hello Spring Boot,"+configBean.getName(); } public static void main(String[] args) { SpringApplication.run(FirstdemoApplication.class, args); } }
View Code
四。
运行结果:
相关文章推荐
- spring boot1.5以上版本@ConfigurationProperties取消location注解后的替代方案
- spring boot1.5以上版本@ConfigurationProperties取消location注解后的替代方案 cannot resolve method location
- spring boot1.5以上版本@ConfigurationProperties取消location注解后的替代方案
- spring boot1.5.X以上版本@ConfigurationProperties取消location注解后的替代方案
- Spring Boot1.4版本后@ConfigurationProperties注解舍弃location参数后的解决方式
- spring boot1.5.X以上版本@ConfigurationProperties注解没有location属性后的替代用法
- spring boot 学习使用@ConfigurationProperties注解
- springboot项目接入配置中心,实现@ConfigurationProperties的bean属性刷新方案
- 学习Spring boot 注解 @Value @Component @ConfigurationProperties
- springboot @value和@configurationproperties注解的区别
- 在Spring Boot中使用 @ConfigurationProperties 注解
- spring boot:使用@ConfigurationProperties注解加载配置文件
- Spring Boot核心原理-自动配置 以及@ConfigurationProperties 注解
- 在Spring Boot中使用 @ConfigurationProperties 注解
- Spring Boot 使用@ConfigurationProperties注解获取配置文件中的值
- spring boot @ConfigurationProperties @EnableConfigurationProperties 配置注解使用
- 在Spring Boot中使用 @ConfigurationProperties 注解
- spring boot 使用@ConfigurationProperties
- 在spring-boot中使用@ConfigurationProperties
- SpringBoot学习之配置文件注入@ConfigurationProperties