当前位置: 首页 > 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.zqtcl.cn/news/830625/

相关文章:

  • 建设部网站招标投标文件网页设计专业公司
  • 使用iis6搭建网站wordpress调用搜索功能
  • 装配式建筑网站生活家装饰
  • 怎样做软件网站建设百度网站认证官网
  • phpcms网站什么网站都能进的浏览器
  • 建设配资网站有要求吗网站建设不一定当地
  • 永兴网站开发智慧门店管理服务平台
  • 网站建设前的市场分析李炎辉网站建设教程
  • 乱起封神是那个网站开发的?广州市建设注册中心网站首页
  • 网站开发配置网络广告的投放技巧
  • wordpress 漫画网站安徽省建设厅八大员报名网站
  • 音乐网站排名建设部证书查询网站
  • 长沙建站挺找有为太极wordpress eshop 教程
  • 郑州平台类网站网站开发常见面试题
  • 城乡建设网站职业查询系统做网站设计的需要什么材料
  • ui做的好看的论坛网站加工制造网
  • 南庄网站开发厦门建设局网站城市建设
  • 常州网站建设效果重庆招聘网
  • 做视频网站需要多大的带宽公众号怎么开通直播功能
  • 信息化网站建设引言南宁 网站建设
  • 怎么做外贸网站的邮箱签名做网站页面怎么做
  • 做文库网站怎么赚钱吗百度网盘下载官网
  • 带后台的网站模板下载wordpress文章置顶插件
  • 云阳营销型网站建设北京梵客装饰公司地址电话
  • 北京有哪些网站建设公司好网站做配置文件的作用
  • 网站制作定制做网站顾客提现金额后台
  • 歙县建设银行网站人员优化是什么意思
  • 网站建设需解决问题wp商城
  • 简单房地产网站在哪老版建设银行网站
  • 外贸网站如何做推广苏州小程序需要写网站建设方案书