赞
踩
目录
SpringBoot中的starter是一种非常重要的机制,能够抛弃以前繁杂的配置,将其统一集成进starter,应用者只需要在maven中引入starter依赖,SpringBoot就能自动扫描到要加载的信息并启动相应的默认配置。starter让我们摆脱了各种依赖库的处理,需要配置各种信息的困扰。SpringBoot会自动通过classpath路径下的类发现需要的Bean,并注册进IOC容器。SpringBoot提供了针对日常企业应用研发各种场景的spring-boot-starter依赖模块。所有这些依赖模块都遵循着约定成俗的默认配置,并允许我们调整这些配置,即遵循“约定大于配置”的理念。
官方:spring-boot-starter-xxx
自定义:xxx-spring-boot-starter
这里我们编写一个发送http请求的starter
根据需要引入依赖,Spring Configuration Processor 可以自动生成配置时的代码提示
创建spring工程后,可以在pom文件里看到当前项目的 GAV
然后删除 bulid 模块
引入 hutool 依赖,使用hutool的 Http客户端工具类来发送http请求。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。