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

做网站客户总是要退款2021年网络十大关键词

做网站客户总是要退款,2021年网络十大关键词,亚马逊云搭建WordPress,如何建设网站咨询跳转页面SpringBoot条件装配注解 Spring Boot 提供了一系列条件装配注解,用于控制 Bean 的创建和装配过程。以下是一些常用的条件装配注解及其详细介绍: ConditionalOnClass 作用:当类路径中存在指定的类时,才会创建该 Bean。 示例&#…

SpringBoot条件装配注解

Spring Boot 提供了一系列条件装配注解,用于控制 Bean 的创建和装配过程。以下是一些常用的条件装配注解及其详细介绍:
@ConditionalOnClass
作用:当类路径中存在指定的类时,才会创建该 Bean。
示例:

 @ConditionalOnClass(RedisTemplate.class)@Beanpublic SimpleCacheService<K, V> redisTemplateService(RedisTemplate<K, V> redisTemplate) {return new RedisCacheService<>(redisTemplate);}

说明:只有当类路径中存在 RedisTemplate 类时,才会创建 redisTemplateService Bean。

@ConditionalOnMissingClass
作用:当类路径中不存在指定的类时,才会创建该 Bean。
示例:

 @ConditionalOnMissingClass("org.springframework.data.redis.core.RedisTemplate")@Beanpublic SimpleCacheService<K, V> fallbackCacheService() {return new FallbackCacheService<>();}

说明:只有当类路径中不存在 RedisTemplate 类时,才会创建 fallbackCacheService Bean。

@ConditionalOnBean
作用:当容器中存在指定类型的 Bean 时,才会创建该 Bean。
示例:

 @ConditionalOnBean(RedisTemplate.class)@Beanpublic CacheManager cacheManager(RedisTemplate<K, V> redisTemplate) {return new RedisCacheManager(redisTemplate);}

说明:只有当容器中存在 RedisTemplate Bean 时,才会创建 cacheManager Bean。

@ConditionalOnMissingBean
作用:当容器中不存在指定类型的 Bean 时,才会创建该 Bean。
示例:

 @ConditionalOnMissingBean(SimpleCacheService.class)@Beanpublic SimpleCacheService<K, V> inMemoryCacheService() {return new InMemoryCacheService<>();}

说明:只有当容器中不存在 SimpleCacheService Bean 时,才会创建 inMemoryCacheService Bean。

@ConditionalOnProperty
作用:当配置文件中的某个属性满足特定条件时,才会创建该 Bean。
示例:

 @ConditionalOnProperty(name = "cache.type", havingValue = "redis")@Beanpublic SimpleCacheService<K, V> redisTemplateService(RedisTemplate<K, V> redisTemplate) {return new RedisCacheService<>(redisTemplate);}

说明:只有当配置文件中 cache.type 属性的值为 redis 时,才会创建 redisTemplateService Bean。

@ConditionalOnExpression
作用:当 SpEL 表达式的结果为 true 时,才会创建该 Bean。
示例:

 @ConditionalOnExpression("${cache.enabled:true}")@Beanpublic SimpleCacheService<K, V> cacheService() {return new DefaultCacheService<>();}

说明:只有当配置文件中的 cache.enabled 属性为 true 或未设置时,才会创建 cacheService Bean。

@ConditionalOnWebApplication@ConditionalOnNotWebApplication
作用:分别在 Web 应用程序和非 Web 应用程序中生效。
示例:

 @ConditionalOnWebApplication@Beanpublic WebService webService() {return new DefaultWebService();}@ConditionalOnNotWebApplication@Beanpublic NonWebService nonWebService() {return new DefaultNonWebService();}

这些注解可以帮助开发者根据不同的运行环境和配置条件来动态装配 Bean,提高应用的灵活性和可扩展性。

http://www.dtcms.com/wzjs/228899.html

相关文章:

  • 电商网站设计工作内容网站首页模板
  • 做网站用什么样的电脑百度seo原理
  • 福田欧曼服务站电话培训优化
  • 毕业设计难度适中的网站开发项目题目cps推广是什么意思
  • 盐城代运营网站推广seo方法
  • 学网站建设课程人工智能培训
  • 基础做网站的小结广告类的网站
  • 做视频的网站那几个盈利了google谷歌搜索引擎入口
  • 网站配色案例百度网站链接
  • 如何建立网站站点郑州专业seo首选
  • 门网站建设在线培训考试系统
  • 蚌埠市网站建设公司什么优化
  • 东莞市网站建设公司谷歌排名网站优化
  • 南昌市住房和城乡建设网站口碑营销
  • 怎样做约票的网站意思看b站视频软件下载安装
  • 厦门做点击付费网站宜昌网站建设公司
  • 劳务公司网站建设网络seo首页
  • 网站毕业设计选题投稿平台
  • 做网站在线支付系统多少钱?域名权重是什么意思
  • 看一个网站是哪里做的登封网络推广
  • 鸡西seo顾问知乎seo优化
  • 烟台教育网站建设拓客软件哪个好用
  • 一般做网站用什么字体比较合适今日头条新闻推荐
  • 江山网站建设百度seo指数查询
  • 佛山做app网站网络营销策划ppt范例
  • 网站分站是怎么做的兰州seo关键词优化
  • 最火的主题wordpresswindows优化大师怎么样
  • wordpress国外博客主题seo外链建设的方法
  • 亚马逊网站建设目的百度搜索引擎优化方案
  • 苏州网站建设与网络推广seo建站网络公司