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

网站建设 部署与发布视频教程如今做知乎类网站怎么样

网站建设 部署与发布视频教程,如今做知乎类网站怎么样,曲阜做网站,鸿鹄网站建设starter1. target2. 手写启动器~2.1 自动装配#xff0c;自定义属性2.2 启动器#xff0c;引用自动装配模块3. 在自己的项目引用上面的starter1. target 1. 启动器只用来做依赖导入(导入配置模块)2. 专门来写一个自动配置模块3. 启动器依赖自动配置#xff1b;别人只需要引入… starter1. target2. 手写启动器~2.1 自动装配自定义属性2.2 启动器引用自动装配模块3. 在自己的项目引用上面的starter1. target 1. 启动器只用来做依赖导入(导入配置模块)2. 专门来写一个自动配置模块3. 启动器依赖自动配置别人只需要引入启动器starterxxx-spring-boot-starter; 自定义启动器名分析 一个启动器需要两个模块一个是自动装配模块自动装配属性定义好装配规则。 第二个是启动器引用自动配置模块。 将两个项目打包到maven仓库或者私服仓库 自己的其它项目引用启动器就行了 在yaml或者properties中配置好启动器的属性就行了。需要的注解 Configuration 指定这是一个配置类ConditionalOnXXX 指定条件成立下自动配置类生效AutoConfigureAfter 指定自动配置的顺序Bean 给容器中添加组件ConfigurationProperites 结合xxxProperties 类绑定相关的配置EnableConfigurationProperties // 让xxxProperties生效加入容器中自动配置类如何能加载将需要启动就加载的自动配置类配置在META-INF/spring.properteis 中2. 手写启动器~ 2.1 自动装配自定义属性 自动配置pom只留下下面的依赖 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.3.4.RELEASE/versionrelativePath/ /parent!-- 自动配置模块... --groupIdcn.bitqian/groupIdartifactIdbitqian-spring-boot-starter-autoconfigurer/artifactIdversion0.0.1-SNAPSHOT/versionnamebitqian-spring-boot-starter-autoconfigurer/namedescriptionDemo project for Spring Boot/descriptionpropertiesjava.version1.8/java.version/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter/artifactId/dependency/dependencies/project 启动器的属性boot中常见的xxxProperties类 package cn.bitqian.starter;import org.springframework.boot.context.properties.ConfigurationProperties;ConfigurationProperties(prefix bitqian.hello) // 配置别名 public class HelloProperties {/*** 可以配置的属性前缀*/private String prefix;/*** 可以自动装配的属性后缀*/private String suffix;public String getPrefix() {return prefix;}public void setPrefix(String prefix) {this.prefix prefix;}public String getSuffix() {return suffix;}public void setSuffix(String suffix) {this.suffix suffix;} } 启动器功能方法 package cn.bitqian.starter;/*** author echo lovely* date 2020/11/8 11:39*/ public class HelloService {private HelloProperties helloProperties;public HelloProperties getHelloProperties() {return helloProperties;}public void setHelloProperties(HelloProperties helloProperties) {this.helloProperties helloProperties;}/*** 启动器的方法配置前后缀实现sayHello* param name parameter* return string*/public String sayHello(String name) {return helloProperties.getPrefix() name helloProperties.getSuffix();}} 自动装配类 package cn.bitqian.starter;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;// 配置类 Configuration ConditionalOnWebApplication // web应用才能生效 EnableConfigurationProperties(HelloProperties.class) // 让属性文件生效 public class HelloServiceAutoConfiguration {Autowiredprivate HelloProperties helloProperties;Beanpublic HelloService helloService() {HelloService helloService new HelloService();helloService.setHelloProperties(helloProperties);return helloService;}} 创建META-INF文件夹配置自动装配类在spring.factories里面 # Auto Configure org.springframework.boot.autoconfigure.EnableAutoConfiguration\ cn.bitqian.starter.HelloServiceAutoConfiguration 双击安装到maven仓库 2.2 启动器引用自动装配模块 启动器模块依赖自动配置模块 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersion!-- 启动器 --groupIdcn.bitqian/groupIdartifactIdbitqian-spring-boot-starter/artifactIdversion1.0-SNAPSHOT/version!-- bitqian springboot 启动器依赖导入 --dependenciesdependencygroupIdcn.bitqian/groupIdartifactIdbitqian-spring-boot-starter-autoconfigurer/artifactIdversion0.0.1-SNAPSHOT/version/dependency/dependencies/project 安装到maven仓库 3. 在自己的项目引用上面的starter 创建springboot项目引入依赖 编写controller package cn.bitqian;import cn.bitqian.starter.HelloService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RestController public class DemoController {AutowiredHelloService helloService;RequestMapping(/hello)public String hello() {return hello, helloService.sayHello( rye );}} 自动装配, 嘤嘤嘤 bitqian.hello.prefixi like bitqian.hello.suffixso much so- - -
http://www.zqtcl.cn/news/902903/

相关文章:

  • 备案 网站名称 怎么改深圳建网站公司
  • html 企业网站模板网站策划书免费
  • 网站建设销售ppt拖拽建站系统源码
  • 网站托管费用多少网站的开发流程
  • 周到的商城网站建设北京品牌网站
  • 网站开发费用属于什么科目网站建设考试多选题
  • c asp做网站wordpress4.5.2文章采集
  • 百度网站建设电话建立网站站建设可以吗
  • 网站后台代码在哪修改网站如何做下一页
  • 网站开发职业要求百度推广代理商与总公司的区别
  • 西安网站建设中心网页 网 址网站区别
  • 技术支持东莞网站建设机械seo岗位是什么意思
  • 做商城网站需要备案什么域名硬件开发工具有哪些
  • 网络网站制作技巧wordpress全文
  • 韩国原生ip站群服务器左右悬停代码网站
  • 专门做广东11选5的网站网站 备案 营业执照
  • 免费扑克网站wordpress弹出服务协议窗口
  • 网站的反爬一般怎样做网站右键屏蔽
  • 茂名做网站dyiee青岛宣传片制作公司
  • 凡科网可以自己做网站吗编程常用网站
  • 做网站练手项目公司营业执照可以做几个网站
  • 聚通达网站建设网站并发要求
  • 网站建设预算申请如何写服装店网页设计素材
  • 做网站设计的公司柳州芜湖又出现一例
  • 重庆网站网站建设东莞市网站建设公司哪家好
  • php做网站如何架构wordpress 排版
  • wordpress免费网站模板下载地址在北京注册公司需要多少钱
  • 做的网站打不开高端网站名字
  • 个人网站建设报告西安网站开发高端网站开发
  • “网站建设:上海珍岛”网站备案信息查询系统