当前位置: 首页 > news >正文

推荐一个免费网站网站开发详细设计

推荐一个免费网站,网站开发详细设计,尚品宅配网站建设,中山企业建网站介绍 Spring Boot中的Binder类是一个用于绑定属性的工具类。它可以将配置文件中的属性值绑定到Java对象中#xff0c;从而方便地进行配置管理。 简单示例 import org.springframework.boot.context.properties.bind.Binder; import org.springframework.core.env.Environmen…介绍 Spring Boot中的Binder类是一个用于绑定属性的工具类。它可以将配置文件中的属性值绑定到Java对象中从而方便地进行配置管理。 简单示例 import org.springframework.boot.context.properties.bind.Binder; import org.springframework.core.env.Environment;Data public class MyConfig {private String name;private int age;public MyConfig(Environment environment) {Binder binder Binder.get(environment);this.name binder.bind(myconfig.name, String.class).orElse(lucifer);this.age binder.bind(myconfig.age, Integer.class).orElse(25);} }使用Binder类将配置文件中的属性值绑定到这些属性中。在构造函数中首先获取了一个Binder实例然后使用bind方法将配置文件中的属性值绑定到Java对象中。如果属性不存在则使用默认值。 配置文件中属性 myconfig.nameJohn myconfig.age25需要将Environment对象传递给MyConfig的构造函数以便Binder类可以访问配置文件中的属性值。在Spring Boot应用程序中可以通过Autowired注解将Environment对象注入到MyConfig类中。 import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment;Configuration public class AppConfig {Autowiredprivate Environment environment;public MyConfig myConfig() {return new MyConfig(environment);} }常用方法 bind方法将配置文件中的属性值绑定到Java对象中。 ConfigurationProperties(prefix example) Data public class ExampleProperties {private String name;private int age; }ExampleProperties properties new ExampleProperties(); Binder binder Binder.get(environment); binder.bind(example, Bindable.ofInstance(properties));bindOrCreate方法如果Java对象不存在则创建一个新的对象并将配置文件中的属性值绑定到该对象中。 ExampleProperties properties Binder.get(environment).bindOrCreate(example, Bindable.of(ExampleProperties.class));bindProperty方法将配置文件中的单个属性值绑定到Java对象的属性中。 ExampleProperties properties new ExampleProperties(); Binder binder Binder.get(environment); binder.bindProperty(example.name, Bindable.ofInstance(properties), String.class);bindAnnotations方法将Java对象中带有ConfigurationProperties注解的属性绑定到配置文件中的属性值。 Data ConfigurationProperties(prefix example) public class ExampleProperties {private String name;private int age; }ExampleProperties properties new ExampleProperties(); Binder binder Binder.get(environment); binder.bindAnnotations(properties);
http://www.hkea.cn/news/14417393/

相关文章:

  • 手机软件做的相册怎样传到网站天台县建设局官方网站
  • 八上电脑课做网站需要什么软件东莞企业大全名录
  • html5彩票网站模板佛山 网站
  • 大连高端网站建设wordpress如何重装
  • 公司网站开发找哪家著名的个人网站
  • 那个网站做玉石最专业长安镇做网站
  • 贵州住房和城乡建设局网站网站开发html
  • 开发型网站报价方法成都最好的效果图公司
  • 农村建设房子建设网站建设显示电脑没有安装wordpress
  • 平江网站建设百度网站官网网址
  • 彩票网站定制网站页面模板
  • 创立网站成本网站建设后期需要后期做的
  • 网站推广软文代发打开2345网址
  • 网站开发采用了哪些技术怎么写网站优化细节
  • 本溪做网站的哪些网站是用wordpress搭建的
  • 视频网站开发研究背景做网站设计制作的
  • 济南网站备案程序想做网站的客户在哪找
  • 个人网站开发可行性报告南海佛山网站建设
  • 惠州品牌网站建设价格推广普通话的文章
  • 分页网站制作一个app的完整流程
  • 9i网站建设如何将下载好的网站模板用到织梦程序上
  • 黑龙江省建设厅网站的电话如果在浏览器上做一网站广告大约需要多少钱
  • 13572074638网站建设云南安宁做网站的公司
  • 商城购物网站开发背景免费建立网站哪个好
  • 渭南华阴建设银行的网站是多少网站建设的运作原理
  • 2880元网站建设wordpress如何修改首页模板
  • 网站建站代理phpnow 安装wordpress
  • 做网站和推广工资多少钱wordpress不能外部链接
  • 专做正品 网站今天重大新闻头条新闻国际新闻
  • 长沙城市建设档案馆网站做网站一般都用什么字体