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

做淘宝客怎样建网站wordpress谷歌地图插件怎么用

做淘宝客怎样建网站,wordpress谷歌地图插件怎么用,移动应用软件开发,乌兰察布做网站公司Configuration注释中的proxyBeanMethods参数是springboot1.0#xff0c;升级到springboot2.0之后新增的比较重要的内容#xff0c;该参数是用来代理bean的。 理论 首先引出两个概念#xff1a;Full 全模式#xff0c;Lite 轻量级模式 Full(proxyBeanMethods true) :pro…Configuration注释中的proxyBeanMethods参数是springboot1.0升级到springboot2.0之后新增的比较重要的内容该参数是用来代理bean的。 理论 首先引出两个概念Full 全模式Lite 轻量级模式 Full(proxyBeanMethods true) :proxyBeanMethods参数设置为true时即为Full 全模式。 该模式下注入容器中的同一个组件无论被取出多少次都是同一个bean实例即单实例对象在该模式下SpringBoot每次启动都会判断检查容器中是否存在该组件 Lite(proxyBeanMethods false) :proxyBeanMethods参数设置为false时即为Lite 轻量级模式。该模式下注入容器中的同一个组件无论被取出多少次都是不同的bean实例即多实例对象在该模式下SpringBoot每次启动会跳过检查容器中是否存在该组件 什么时候用Full全模式什么时候用Lite轻量级模式 当在你的同一个Configuration配置类中注入到容器中的bean实例之间有依赖关系时建议使用Full全模式 当在你的同一个Configuration配置类中注入到容器中的bean实例之间没有依赖关系时建议使用Lite轻量级模式以提高springboot的启动速度和性能 proxyBeanMethods 属性默认值是 true, 也就是说该配置类会被代理CGLIB在同一个配置文件中调用其它被 Bean 注解标注的方法获取对象时会直接从 IOC 容器之中获取  源码注解 /**      * Specify whether {code Bean} methods should get proxied in order to enforce      * bean lifecycle behavior, e.g. to return shared singleton bean instances even      * in case of direct {code Bean} method calls in user code. This feature      * requires method interception, implemented through a runtime-generated CGLIB      * subclass which comes with limitations such as the configuration class and      * its methods not being allowed to declare {code final}.      * pThe default is {code true}, allowing for inter-bean references via direct      * method calls within the configuration class as well as for external calls to      * this configurations {code Bean} methods, e.g. from another configuration class.      * If this is not needed since each of this particular configurations {code Bean}      * methods is self-contained and designed as a plain factory method for container use,      * switch this flag to {code false} in order to avoid CGLIB subclass processing.      * pTurning off bean method interception effectively processes {code Bean}      * methods individually like when declared on non-{code Configuration} classes,      * a.k.a. Bean Lite Mode (see {link Bean Beans javadoc}). It is therefore      * behaviorally equivalent to removing the {code Configuration} stereotype.      * since 5.2      */     boolean proxyBeanMethods() default true;   注解的意思是 proxyBeanMethods 配置类是用来指定 Bean 注解标注的方法是否使用代理默认是 true 使用代理直接从 IOC 容器之中取得对象如果设置为 false, 也就是不使用注解每次调用 Bean 标注的方法获取到的对象和 IOC 容器中的都不一样是一个新的对象所以我们可以将此属性设置为 false 来提高性能 根据注释 proxyBeanMethods 是为了让使用 Bean 注解的方法被代理而实现 bean 的生命周期的行为。 设置为 true那么直接调用方法获取 bean不会创建新的 bean而是会走 bean 的生命周期的行为。设置为 false, 那么直接调用方法获取 bean会创建新的 bean且不会走 bean 的生命周期的行为。 测试代码 public class AnnotationConfigApplicationContextTest {Testpublic void refresh(){AnnotationConfigApplicationContext ctxnew AnnotationConfigApplicationContext();ctx.register(AppConfig.class);ctx.refresh();MyBean myBeanctx.getBean(MyBean.class);myBean.sayHello();YourBean yourBeanctx.getBean(YourBean.class);yourBean.sayHello();}Configuration 代码设置为 false Configuration(proxyBeanMethods false) public class AppConfig {Beanpublic MyBean myBean(){return new MyBean();}Beanpublic YourBean yourBean(){return new YourBean(myBean());} } Mybean 代码 public class MyBean {public MyBean(){System.out.println(MyBean construct......);}PostConstructpublic void init(){System.out.println(MyBean PostConstruct ....);}public void sayHello(){System.out.println(Hi MyBean ,hello world!);} } YourBean 代码 public class YourBean {public MyBean myBean;public YourBean(MyBean myBean){System.out.println(YourBean construct...);this.myBeanmyBean;}PostConstructpublic void init(){System.out.println(YourBean PostConstruct...);}public void sayHello(){System.out.println(Hi YourBean ,hello world!);} } 执行 refresh 测试测试代码结果proxyBeanMethods false MyBean construct...... 打印了两次说明被 new 了两次 10:04:56.066 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean myBean MyBean construct...... MyBean PostConstruct .... 10:04:56.069 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean yourBean MyBean construct...... YourBean construct... YourBean PostConstruct... Hi MyBean ,hello world! Hi YourBean ,hello world! 执行 refresh 测试测试代码结果proxyBeanMethods true  MyBean construct...... 只打印了一次说明只被 new 了一次。 10:06:51.727 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean myBean MyBean construct...... MyBean PostConstruct .... 10:06:51.741 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean yourBean YourBean construct... YourBean PostConstruct... Hi MyBean ,hello world! Hi YourBean ,hello world!
http://www.hkea.cn/news/14304770/

相关文章:

  • 怎么制作网站内容自豪地采用wordpress 怎么去掉
  • 网站数据库怎么备份营业执照几年不审自动注销
  • 吉林市今天消息seo网络科技有限公司
  • 静态网站代做中山企业门户网站建设
  • 企业网站信息化建设网站外链如何建设最有用
  • 山东小语种网站建设好的软件开发培训机构
  • 上海电子商务网站视觉设计网站建设
  • 网站404怎么做视频教程北京seo公司公司
  • 小型网站建设的经验网站建设培训需要多少钱
  • 10元建站中国建筑网官网查询阮国方
  • 女装网站建设文献综述广州市招标采购网官网
  • 别人做的网站不能用常州抖音seo
  • 国内十个免费自学网站建筑网招工网
  • 卫计局本年度网站建设工作总结什么系统做网站最安全
  • 摩托车专业网站建一个私人彩票网站
  • 上海哪里有做网站的珠海视窗网
  • 广东品牌网站建设报价表建设网站可以做什么
  • php语言做网站泉州微信网站开发
  • 广州网站建设联享科技合肥小程序建设
  • 宁波建设银行管方网站淄博网站文章优化
  • 网站评论怎么做的怎么看网站被惩罚
  • 大兴专业网站建设公司有个专门做dnf游戏币的网站
  • 网站底部广告代码淘宝上做网站权重
  • 有哪些网站是可以做宣传的电商网站图片是谁做
  • 凤翔网站制作成都网络营销公司排名收费标准
  • 宝安做棋牌网站建设多少钱咚门wordpress
  • 现在能用的网站网站不备案不能用吗
  • jsp网站开发制作wordpress+电脑微信登陆不了
  • 扬中网站建设价格360首页
  • 无锡宏腾网站建设湖南人工智能建站系统软件