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

中文网站的seo怎么做phpcms做网站

中文网站的seo怎么做,phpcms做网站,网页设计需要学什么内容,北京seo代理计费Conditional条件装配 Conditional是Spring Framework提供的一个核心功能注解#xff0c;这个注解的作用是提供自动装配的条件限制#xff0c;一般我们在用Configuration#xff0c;Bean的时候使用它。也就是我们在自定义Bean的注入的时候#xff0c;我们可以通过Condition…Conditional条件装配 Conditional是Spring Framework提供的一个核心功能注解这个注解的作用是提供自动装配的条件限制一般我们在用ConfigurationBean的时候使用它。也就是我们在自定义Bean的注入的时候我们可以通过Condition来对bean的注入增加逻辑判断符合我们要求的我们才让他自动装配 Conditional 的使用 如下注解源码是Condition FunctionalInterface public interface Condition {/*** Determine if the condition matches.* param context the condition context* param metadata metadata of the {link org.springframework.core.type.AnnotationMetadata class}* or {link org.springframework.core.type.MethodMetadata method} being checked* return {code true} if the condition matches and the component can be registered,* or {code false} to veto the annotated components registration*/boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata);}condition是一个函数式接口提供了一个matches方法主要提供一个条件匹配的规则返回表示是否可以注入Bean。 Conditional 的注解来声明如下他可以接受接收一个Condition的数组 Target({ElementType.TYPE, ElementType.METHOD}) Retention(RetentionPolicy.RUNTIME) Documented public interface Conditional {/*** All {link Condition Conditions} that must {linkplain Condition#matches match}* in order for the component to be registered.*/Class? extends Condition[] value();}Conditional使用Demo 我们通过对以上Conditional的了解来自己实现一个Bean的按自定义条件的装配定义一个Condition判断系统来返回是否装配 /*** Created by jiamin5 on 2022/3/10.*/ public class GpCondition implements Condition{private static final Logger logger LoggerFactory.getLogger(GpCondition.class);Overridepublic boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {String os context.getEnvironment().getProperty(os.name);logger.info(GpCondition matthes osName:{}, os);if(os.contains(Windows)){return true;}return false;} }定义配置类装载一个BeanTestClass /*** Created by jiamin5 on 2022/3/10.*/ Configuration public class ConditionConfig {BeanConditional(GpCondition.class)public BeanTestClass beanTestClass(){return new BeanTestClass();} }如上我们在BeanTestClass上增加了一个Conditional(GpCondition.class)其中的具体条件就是我们自定义的注入限制条件类。意思就是当条件满足我们定义的GpCondition的时候我们就注入否则不注入。依然在Application启动类中添加对新定义Bean的获取如下 /*** author liaojiamin* Date:Created in 11:08 2022/3/7*/ SpringBootApplication EnableAutoImport public class Application {public static void main(String[] args) {ConfigurableApplicationContext ca SpringApplication.run(Application.class, args);System.out.println(ca.getBean(FilterFirstObj.class));BeanTestClass beanTestClass ca.getBean(BeanTestClass.class);System.out.println(beanTestClass);} } 当我们在Mac os上运行有如下结果 Spring Boot 中的Conditional 在SpringBoot中有针对Conditional的扩展提供了更简单的使用方式扩张了各种类型的注解如下 ConditionalOnBean/ConditionalOnMissBean 容器中存在或者不存在某个类的时候进行Bean加载ConditionalOnClass/ConditionalOnMissClassclasspath下存在或者不存在指定类的时候进行Bean加载ConditionalOnCloudPlatform只允许在指定的云平台上才加载指定BeanConditionalOnExpression基于SpEl表达式的条件判断ConditionalOnJava只允许在指定版本Java才加载BeanConditionalOnJndi只有指定资源通过JNDI加载后才加载BeanConditionalOnWebApplication/ConsitionalOnNotWebApplication如果是活着不是web应用才加载指定的BeanConditionalOnProperty系统中指定对呀的属性是否有对应值ConditionOnResource要加载的Bean依赖指定资源是否存在于classpathConditionOnSingleCandidate只有在确定了给定Bean的单个候选项时候才会加载Bean 以上这些都在spring-boot-autoconfiguration.jar 中 其他注入方式spring-autoconfigure-metadata 除了Conditional注解。Spring Boot中提供了spring-autoconfigure-metadata.properties文件来实现批量自动装配条件配置 与Conditional意义只是将条件放在的文件我们可以在spring-boot-autoconfigure.jar中找到这种配置 同样遵循“约定由于配置”通过这种配置实现条件过滤需保证两个前提条件 如上图中文件路径名称必须是/META-INF/spring-autoconfigure-metadata.properties配置文件的key’的配置格式自动配置类的类全路径名.条件 值 这种配置优点在于可以有效降低Spring Boot启动时间通过这种过滤方式减少配置陪的加载数量因为这个过滤发生在配置类的装载之前所以他可以降低Spring Boot启动时装载Bean的耗时 上一篇SpringBoot自动装配源码解析
http://wiki.neutronadmin.com/news/395079/

相关文章:

  • asp做网站和dw的区别买产品做企业网站还是博客
  • 网站建设电话销售技巧和话术大学生做家教网站
  • app网站开发哪里有施工企业年终总结及明年工作计划
  • 网站模板无忧网站优化网络
  • 延吉有没有做网站的如何搭建网上商城
  • 如何写网站代码是什么原因wordpress文件存放不同目录
  • 建网站的网站有哪些上海高端品牌网站建设
  • 网站手机版怎么弄软文发稿
  • 深圳设计公司企业网站上海市电话黄页本
  • 2019网站怎么做如何在手机上做广告
  • 多个网站 备案吗wordpress5.0.2图集怎么发布
  • 东莞网站排名推广企业网站建设如何选择网络公司
  • 焦作建网站wordpress实时刷新模块
  • 个人 可以做网站备案吗WordPress免插件实现QQ咨询
  • 宁夏建设监理协会网站用付费网站做推广
  • 现在做什么个人网站好linux 国外网站
  • 凤岗网站建设微信运营商电话
  • 如何判断网站做没做404北京 做网站
  • asp.net 网站图标做二手车网站怎么做的
  • 打电话来说做网站 然后答应了怎么建设游网站主页
  • 重庆网站仿站手机建站系统
  • 昆山网站制作哪家好中信建设有限责任公司刚果金
  • 免费建站的方法流程怎么让别人做网站
  • 在国外服务器上做网站项目如何赚钱好用的代码网站
  • 网站设计可以在手机上做吗wordpress 500 - 内部服务器错误
  • 完成网站开发需要什么样技术vs2010网站设计用整张图片做背景
  • 建设外贸网站费用智慧团建手机登录端口
  • 网站seo收录工具wordpress 占用cpu
  • 许昌建设局网站google推广方式和手段有哪些
  • 网站取消备案免费的宣传方式