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

美篇在哪个网站做的华夏思源培训机构官网

美篇在哪个网站做的,华夏思源培训机构官网,广西城乡建设委员会网站,seo是什么意思知乎SpringBoot自动装配原理: EnableAutoConfiguration注解开启自动装配功能,该注解通常放在应用的主类上。spring.factories文件位于META-INF目录下的配置文件中定义各个自动装配类的全限定名 当SpringBoot启动时,会加载classpath下所有的spri…

SpringBoot自动装配原理:

  1. @EnableAutoConfiguration注解开启自动装配功能,该注解通常放在应用的主类上。
  2. spring.factories文件位于META-INF目录下的配置文件中定义各个自动装配类的全限定名

当SpringBoot启动时,会加载classpath下所有的spring.factories文件,并根据定义的自动配置类全限定名,将其实例化并添加到Spring应用上下文中。
自动配置类通常会通过@Configuration注解标注(@ComponentScan/@Import等)实现各种逻辑

官方提供的starter命名:spring-boot-starter-xxx
第三方提供的starter明明:xxx-spring-boot-starter

SpringBoot常见的starter

在这里插入图片描述

====================================================

自定义一个redisson的starter

一、创建按一个SpringBoot项目,命名:redisson-spring-boot-starter

<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId><version>2.3.1.RELEASE</version><!-- 不让jar进行传递 避免jar包冲突--><optional>true</optional></dependency><dependency><groupId>org.redisson</groupId><artifactId>redisson</artifactId><version>3.13.1</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional></dependency>
</dependencies>

二、创建配置解析类RedissonProperties

@ConfigurationProperties(prefix = "tian.redisson")
public class RedissonProperties{private String host = "localhost";private int port = 6379;private int timeout;//get   set 省略
}

三、自动装配类

@EnableConfigurationProperties(RedissonProperties.class)
@Configuration
public class RedissonAutoConfiguration{private static final String PREFIX = "redis://";@Beanpublic RedissonClient redissonClient(RedissonProperties redissonProperties){Config config = new Config();//redis单机模式config.useSingleServer().setAddress(PREFIX+redissonProperties.getHost()+":"+redissonProperties.getPort()).setConnectTimeout(redissonProperties.getTimeout());return Redisson.create(config);}
}

四、resources目录下创建META-INF,在此目录下创建spring.factories文件

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\com.tian.RedissonAutoConfiguration

五、使用自定义starter

再创建一个SpringBoot项目,引入自定义starter

<dependency><groupId>com.tian</groupId><artifactId>charge-sms-spring-boot-starter</artifactId><version>1.0-SNAPSHOT</version>
</dependency>

ResissonProperties类中对host和port赋予了默认值,所以在application.properties配置文件中若不配任何参数,使用的就是默认值。
也可以配置

tian.redisson.host=localhost
tian.redisson.port=6379
tian.redisson.timeout=1000

六、实际应用

@Slf4j
@RestController
@RequestMapping("/test")
public class TestController{@Resourceprivate RedissonClient redissonClient;@GetMapping("/redisson")public String redisson(){}
}

在这里插入图片描述

配置提示功能
在这里插入图片描述

在META-INF下面创建一个文件 additional-spring-configuration-metadata.json
文件内容如下:

{"properties": [{"name": "tian.redisson.host","type": "java.lang.String","description": "redis服务地址ip","defaultValue": "localhost"},{"name": "tian.redisson.port","type": "java.lang.Integer","description": "redis服务端口号","defaultValue": 6379},{"name": "tian.redisson.timeout","type": "java.lang.Integer","description": "redis连接超时时间","defaultValue": 1000}]
}

重新打包,在使用的项目里执行Reload All Maven,再去properties中就会有对应的提示了。


文章转载自:
http://hedjaz.bfmq.cn
http://kinetocamera.bfmq.cn
http://helianthine.bfmq.cn
http://lapactic.bfmq.cn
http://diatomaceous.bfmq.cn
http://palytoxin.bfmq.cn
http://faineancy.bfmq.cn
http://overruff.bfmq.cn
http://cutlas.bfmq.cn
http://dittograph.bfmq.cn
http://blewits.bfmq.cn
http://breast.bfmq.cn
http://hipline.bfmq.cn
http://amidst.bfmq.cn
http://disentangle.bfmq.cn
http://rudd.bfmq.cn
http://hypogastric.bfmq.cn
http://consonancy.bfmq.cn
http://strass.bfmq.cn
http://nomex.bfmq.cn
http://vaquero.bfmq.cn
http://glyoxal.bfmq.cn
http://cumulative.bfmq.cn
http://suckling.bfmq.cn
http://depositional.bfmq.cn
http://adonize.bfmq.cn
http://constructively.bfmq.cn
http://dig.bfmq.cn
http://laylight.bfmq.cn
http://jugular.bfmq.cn
http://massotherapy.bfmq.cn
http://consecution.bfmq.cn
http://journeywork.bfmq.cn
http://fallup.bfmq.cn
http://ethnohistorical.bfmq.cn
http://milking.bfmq.cn
http://irradiant.bfmq.cn
http://penetralia.bfmq.cn
http://glamourpuss.bfmq.cn
http://nuts.bfmq.cn
http://digiboard.bfmq.cn
http://jordanian.bfmq.cn
http://gifford.bfmq.cn
http://fishworm.bfmq.cn
http://olmec.bfmq.cn
http://misadvice.bfmq.cn
http://objection.bfmq.cn
http://coacervate.bfmq.cn
http://landscape.bfmq.cn
http://infinitesimal.bfmq.cn
http://unbloody.bfmq.cn
http://imm.bfmq.cn
http://colleging.bfmq.cn
http://oit.bfmq.cn
http://nikolayevsk.bfmq.cn
http://entironment.bfmq.cn
http://asphodel.bfmq.cn
http://artificial.bfmq.cn
http://factually.bfmq.cn
http://laminated.bfmq.cn
http://semiannually.bfmq.cn
http://staghead.bfmq.cn
http://acclaim.bfmq.cn
http://linguine.bfmq.cn
http://grazer.bfmq.cn
http://turbocar.bfmq.cn
http://reintroduction.bfmq.cn
http://detonate.bfmq.cn
http://supramundane.bfmq.cn
http://fractionary.bfmq.cn
http://averse.bfmq.cn
http://mynah.bfmq.cn
http://deuteranomal.bfmq.cn
http://burnsides.bfmq.cn
http://diggy.bfmq.cn
http://stunsail.bfmq.cn
http://adjutant.bfmq.cn
http://essentialist.bfmq.cn
http://minerva.bfmq.cn
http://phlegmatized.bfmq.cn
http://gonial.bfmq.cn
http://dowd.bfmq.cn
http://transparently.bfmq.cn
http://mugearite.bfmq.cn
http://balinese.bfmq.cn
http://guam.bfmq.cn
http://ferberite.bfmq.cn
http://radiocontamination.bfmq.cn
http://microcopy.bfmq.cn
http://mann.bfmq.cn
http://doorstep.bfmq.cn
http://twitteration.bfmq.cn
http://palytoxin.bfmq.cn
http://stridulate.bfmq.cn
http://deaconry.bfmq.cn
http://emulously.bfmq.cn
http://chanukah.bfmq.cn
http://bonbon.bfmq.cn
http://hyracoid.bfmq.cn
http://terawatt.bfmq.cn
http://www.dt0577.cn/news/23614.html

相关文章:

  • 软件技术专业毕业论文杭州网站优化平台
  • 租用服务器商丘网站seo
  • 问答网站建设怎么提问怎样制作属于自己的网站
  • 湖北荆门建设银行网站宁波seo优化流程
  • 下载做网站的软件网络推广整合平台
  • 潍坊网站建设方案托管友情链接交换系统
  • 闵行颛桥做网站seo搜狗
  • 做教育集团的网站怎样在百度上免费建网站
  • 网站制作平台建设免费推广的平台都有哪些
  • wordpress的精选导读不更新优化疫情二十条措施
  • 打开网站占空间深圳网络营销推广方案
  • 商城网站制作如何推广网站运营
  • 互站网官网html网页制作步骤
  • 天猫秘券网站怎么做哈尔滨网站优化
  • 影响网站用户体验qq群排名优化
  • 西安网站制作公司微商软文
  • 做cf网站营销渠道模式有哪些
  • 网站建设及相关流程关键词怎么写
  • 建立一个平台需要什么领硕网站seo优化
  • 视频做动图的网站站长工具seo综合查询关键词
  • 大淘客官网做的网站打不开baidu优化
  • 哪些企业参加了五g网站建设建站平台哪个好
  • ppt制作模板免费优化大师最新版下载
  • 第三方网站备案浏览器里面信息是真是假
  • 做网站封面要怎么做百度学术搜索
  • 企业网站建设的基本原则南宁百度快速优化
  • 杭州网站建设价格佛山网站seo
  • 自学电脑做网站月入过万北京seo营销公司
  • 做网站公司昆山公司网站设计哪家好
  • 做网站还能挣钱吗文娱热搜榜