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

大通证券手机版下载官方网站下载网上推广产品哪个平台效果好

大通证券手机版下载官方网站下载,网上推广产品哪个平台效果好,网页传奇游戏攻略,建设用地规划许可证去哪个网站查ConfigurationProperties使用 ConfigurationProperties是 springboot提供用于将配置文件中的属性值映射到 Java bean对象上。通过使用该注解#xff0c;我们可以方便地将属性文件中的值绑定到一个实例化的类对象上#xff0c;从而方便地在应用程序中使用这些属性。 Configu…ConfigurationProperties使用 ConfigurationProperties是 springboot提供用于将配置文件中的属性值映射到 Java bean对象上。通过使用该注解我们可以方便地将属性文件中的值绑定到一个实例化的类对象上从而方便地在应用程序中使用这些属性。 ConfigurationProperties注解有一个参数prefix用来指定属性公共前缀 Configuration ConfigurationProperties(prefix myconfig) Data public class MyConfigProperty {private int port;//找不到的属性不会注入private String hhh; }一般作为属性注入对象首先定义成一个Configuration。然后使用ConfigurationProperties指定关联属性的前缀。这样如果配置文件中有myconfig.port的值就会自动绑定到MyConfigProperty类的port属性上。前提要有对应的set方法。 除了在类上标注外还可以在Bean方法上 Configuration public class MyConfigByMethod {BeanConfigurationProperties(prefix myconfig)public MyConfig myConfig(){return new MyConfig();} }观察spring的源码还会使用EnableConfigurationProperties引入被ConfigurationProperties修饰的bean 框架自动装配解析 在springboot框架自动装配中有一个内置的用来处理ConfigurationProperties注解的配置类ConfigurationPropertiesAutoConfiguration该配置类引入EnableConfigurationProperties,然后间接引入EnableConfigurationPropertiesRegistrarEnableConfigurationPropertiesRegistrar在configuration初始化的时候会调用其registerBeanDefinitions()方法进行配置类中扩展beanDef的加载。 EnableConfigurationPropertiesRegistrar#registerBeanDefinitions public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {registerInfrastructureBeans(registry);registerMethodValidationExcludeFilter(registry);ConfigurationPropertiesBeanRegistrar beanRegistrar new ConfigurationPropertiesBeanRegistrar(registry);getTypes(metadata).forEach(beanRegistrar::register);}private SetClass? getTypes(AnnotationMetadata metadata) {return metadata.getAnnotations().stream(EnableConfigurationProperties.class).flatMap((annotation) - Arrays.stream(annotation.getClassArray(MergedAnnotation.VALUE))).filter((type) - void.class ! type).collect(Collectors.toSet()); } static void registerInfrastructureBeans(BeanDefinitionRegistry registry) {ConfigurationPropertiesBindingPostProcessor.register(registry);BoundConfigurationProperties.register(registry); }这里主要会完成两件事件 1、registerInfrastructureBeans会将ConfigurationPropertiesBindingPostProcessor注册到容器中这是一个后置处理其属性的赋值会在其后置方法里完成。 2、注册合适的ConfigurationProperties类型bean 当前metadata是正在初始化的Configuration类然后从其注解上获取带有EnableConfigurationProperties注解作为bean定义加载到容器中。 来看几个自动装配的例子 ServletWebServerFactoryAutoConfiguration ServletWebServerFactoryAutoConfiguration上带有EnableConfigurationProperties(ServerProperties.class)注解则ServerProperties会作为一个bean进行处理。ServerProperties上配置有ConfigurationProperties(prefix “server”, ignoreUnknownFields true)我们场景的server.port属性就会注入到ServerProperties.port属性上。 DataSourceAutoConfiguration EnableConfigurationProperties(DataSourceProperties.class) public class DataSourceAutoConfiguration {}ConfigurationProperties(prefix spring.datasource) public class DataSourceProperties{}DataSourceProperties会被做为一个bean加载spring.datasource下的属性会注入到DataSourceProperties属性中。 ConfigurationPropertiesBindingPostProcessor ConfigurationPropertiesBindingPostProcessor是一个bean后置处理器在bean实例化后会调用其后置方法 public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {bind(ConfigurationPropertiesBean.get(this.applicationContext, bean, beanName));return bean; }ConfigurationPropertiesBean.get()方法会判断当前bean是否有ConfigurationProperties注解如果有会进行对应的属性绑定。最后使用org.springframework.boot.context.properties.bind.Binder类进行属性绑定。这里ConfigurationProperties会有两部分一是框架通过autoConfig自动装配的一种是我们自己显示使用ConfigurationProperties修饰的bean。这里看到我们在自定义ConfigurationProperties时候不一定非用Configuration进行修饰只要当前类能被解析成一个bean都会调用该后置方法进行对应配置属性的赋值。 属性元数据信息 可配置的属性在每个jar包META-INFO/spring-configuration-metadata.json文件。这样一般在IDEA配置application文件时候都能根据该文件里的元数据信息进行提示配置。 例如server.port配置在spring-boot-autoconfigure.jar包中 {name: server.port,type: java.lang.Integer,description: Server HTTP port.,sourceType: org.springframework.boot.autoconfigure.web.ServerProperties,defaultValue: 8080 },
http://www.pierceye.com/news/194902/

相关文章:

  • 权威做网站的公司网站织梦程序改成wordpress
  • 用cms建网站容易吗平面设计网课平台哪个好
  • 网站设计怎么做好什么视频直播网站做挣钱
  • 西安 网站开发 招聘app开发难吗
  • 富阳网站建设 优帮云邯郸市商标设计品牌策划公司
  • 整站优化费用中国网新重庆
  • 找别人做网站wordpress怎么更改栏目权限
  • 珠海市建设工程质量监督检测站网站在小网站上做点击广告
  • 网站拉圈圈接口怎么做传媒网站设计
  • 淘宝客做的最好的网站盐山建网站
  • 西城企业网站建设深圳设计网站多少钱
  • 电子商务网站建设a卷网站建设厘金手指排名二一
  • 网站空间便宜网站的信息管理建设的必要性
  • 校级特色专业建设网站博达站群网站建设教程
  • 有没有做任务的网站吗网站首页开发
  • 公司名字变了网站备案济南网站建设公司哪个好点呢
  • 图书馆网站建设的规章制度企业免费招聘网站
  • 效果图网站大全系统优化的例子
  • 京东的网站建设介绍网站开发要源码多少钱
  • 东莞网站制作公司报价企业定制
  • 创同盟做网站生成拼贴的网站
  • 网站备案号查电话号码商场网站开发
  • 手机网站建站教育模板下载泰州公司注册
  • 如何做商业网站推广西安市城乡建设管理局网站的公示栏
  • 上海做兼职哪个网站腾讯企业邮箱域名是什么
  • 霸州网站制作棋牌网站建设源码
  • 茶叶网站制作模板网页设计在安阳工资多少
  • 网站建设项目验收方案自己做捕鱼网站能不能挣钱
  • 微信网页网站怎么做我为群众办实事实践活动
  • 建设银行发卡银行网站福州 网站设计