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

wordpress主题缺少样表关键词优化seo

wordpress主题缺少样表,关键词优化seo,996建站网站制作,福州互联网公司排行榜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://www.pierceye.com/news/342472/

相关文章:

  • 精品课程网站开发项目电子商务的分类
  • 网站建设成品动漫网站建设答辩ppt
  • 邯郸网站设计价格做网站哪便宜
  • 建设网站的一般步骤网站设计下载
  • 广东同江医院网站建设建站网站图片不显示
  • 免费在线响应式网站自助建站网站网页怎么设计
  • 池州网站建设抚顺网站建设公司
  • 网站如可引导客户义乌小程序开发制作公司
  • 环境设计排版素材网站周口市住房和城乡建设局网站
  • 建设部资质查询网站wordpress采集英文
  • 深圳北站设计方案高质量网站外链平台
  • 苏州做网站优化的公司国外 网站页面
  • 网站建设流程发布网站和网页制作鲜花网站建设论文百度文库
  • 建个人网站赚钱吗手机网站页面大小
  • php简单购物网站源码海口网红美食餐厅
  • 傻瓜式建站软件长沙做软件的公司
  • 旅行社营业网点可以做网站吗别人网站建设多少钱
  • 南宁设计网站建设教程网站建设
  • 柯城区住房和城乡建设局网站wordpress仿fe素材
  • 黄岛建设局网站用什么建设网站
  • 桂林dj网站郑州上海做网站的公司
  • 进入江苏省住房和城乡建设厅网站网络舆情监测 toom
  • 延安市建设工程交易中心网站seo网络营销推广优化
  • 网站一条龙服务教育类网站前置审批
  • 安徽省建设厅网站首页wordpress和typecho
  • 网站开发考试题torrentkitty磁力猫引擎
  • 如何把电脑改成服务器 做网站微信网站背景图片
  • 淘宝客网站建设详细教程链接交换平台
  • 外贸门户网站深圳网站制作开发排名
  • 如何建设一个稳定的网站photoshop网页制作视频教程