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

网站流量提供商2014网站建设

网站流量提供商,2014网站建设,软件工程4大证书,手机怎么制作自己的网站【README】 本文po出了自建springboot 启动器步骤#xff1b; 【1】新建2个starter相关组件 根据 mybatis-spring-boot-starter#xff0c;我们看到 自建starter需要两个组件#xff0c;分别是 xxx-spring-boot-starter#xff0c; xxx-spring-boot-starter-autoconfigu…【README】 本文po出了自建springboot 启动器步骤 【1】新建2个starter相关组件 根据  mybatis-spring-boot-starter我们看到 自建starter需要两个组件分别是 xxx-spring-boot-starter xxx-spring-boot-starter-autoconfigure 其中xxx-spring-boot-starter负责引入 xxx-spring-boot-starter-autoconfigure 依赖 xxx-spring-boot-starter-autoconfigure 负责定义相关配置 step1新建空项目 项目名称为 springbt-08-starter-diy2 step2在空项目上新建2个组件分别为 lisi-spring-boot-starter 和 lisi-spring-boot-starter-autoconfigure 其中 lisi-spring-boot-starter为 单纯的maven项目 lisi-spring-boot-starter-autoconfigure 通过 spring Initializer 工具创建 step3 lisi-spring-boot-starter 引入 lisi-spring-boot-starter-autoconfigure 依赖 lisi-spring-boot-starter组件的pom.xml 如下 ?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/modelVersiongroupIdcom.cmc.starter/groupIdartifactIdlisi-spring-boot-starter/artifactIdversion1.0-SNAPSHOT/versiondependencies!--引入 lisi-spring-boot-starter-autoconfigure 依赖--dependencygroupIdcom.cmc.starter/groupIdartifactIdlisi-spring-boot-starter-autoconfigure/artifactIdversion0.0.1-SNAPSHOT/version/dependency/dependencies/project 并把测试目标目录删除 lisi-spring-boot-starter目录结构如下 step4 lisi-spring-boot-starter-autoconfigure 组件的pom.xml 如下 删除多余的插件 测试库依赖 ?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.5.5/versionrelativePath/ !-- lookup parent from repository --/parentgroupIdcom.cmc.starter/groupIdartifactIdlisi-spring-boot-starter-autoconfigure/artifactIdversion0.0.1-SNAPSHOT/versionnamelisi-spring-boot-starter-autoconfigure/namedescriptionDemo project for Spring Boot/descriptionpropertiesjava.version1.8/java.version/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter/artifactId/dependency/dependencies/project【2】开发 starter-autoconfigure 启动器配置组件 step1 新建 HelloServiceHelloProperties HelloServiceAutoConfiguration package com.cmc.starter.lisi;import org.springframework.boot.context.properties.ConfigurationProperties;ConfigurationProperties(prefix cmc.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 com.cmc.starter.lisi;public class HelloService {HelloProperties helloProperties;public String sayHelloCmc(String name) {return helloProperties.getPrefix() - name - helloProperties.getSuffix();}public HelloProperties getHelloProperties() {return helloProperties;}public void setHelloProperties(HelloProperties helloProperties) {this.helloProperties helloProperties;} }package com.cmc.starter.lisi;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 {AutowiredHelloProperties helloProperties;Beanpublic HelloService helloService() {HelloService helloService new HelloService();helloService.setHelloProperties(helloProperties);return helloService;} }step2在资源类路径下新建 META-INF/spring.factories 属性文件添加 自动配置类全限定类名 # spring.factories# Auto Config org.springframework.boot.autoconfigure.EnableAutoConfiguration\ com.cmc.starter.lisi.HelloServiceAutoConfiguration 参考的是 spring-boot-autoconfigure.jar 中的 META-INF/spring.factories的内容 目录结构如下 step3先把 lisi-spring-boot-starter-autoconfigure 制品库安装到本地仓库 step4再把 lisi-spring-boot-starter 制品库安装到本地仓库 【3】自建starter使用 step1 新建项目只需要引入 lisi-spring-boot-starter依赖  即可 因为 lisi-spring-boot-starter  引入了 lisi-spring-boot-starter-autoconfigure传递依赖 pom.xml 如下 ?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.5.5/versionrelativePath/ !-- lookup parent from repository --/parentgroupIdcom.cmc/groupIdartifactIdspringboot-08-starter-test2/artifactIdversion0.0.1-SNAPSHOT/versionnamespringboot-08-starter-test2/namedescriptionDemo project for Spring Boot/descriptionpropertiesjava.version1.8/java.version/propertiesdependencies!--引入自定义的starter--dependencygroupIdcom.cmc.starter/groupIdartifactIdlisi-spring-boot-starter/artifactIdversion1.0-SNAPSHOT/version/dependency!-- 测试库 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency!-- springboot web库 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/projectstep2 新建测试项目编写 Controller引入 HelloService import com.cmc.starter.lisi.HelloService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController;RestController public class HelloController {AutowiredHelloService helloService;GetMapping(/hello)public String hello() {return helloService.sayHelloCmc(zhangsan);} } step3HelloServiceAutoConfiguration有两个属性前缀后缀需要配置在 application.properties 中配置如下 cmc.hello.prefixchengdu cmc.hello.suffix028 step4启动springboot项目并访问 localhost:8080/hello ;
http://www.zqtcl.cn/news/525740/

相关文章:

  • 佛山网站开发公司做网站在什么地方发帖子呢
  • 无网站可以做cpc吗wordpress 12张表
  • 有些中小网站cnzz网站排名是怎么做的
  • 深圳做微商网站的公司高端做网站价格
  • 在线原型设计网站wordpress菜单页内跳转
  • 做电影网站要买什么抖音推广怎么收费
  • 专业的公司网站开发网站按钮设计
  • 南宁网站建设是什么深圳公司有哪些
  • 杭州手机申请网站登录怎么做电子商务网站
  • 青岛个人接网站建设wordpress 转载文章
  • 网上做网站任务网络营销传播的核心内容
  • 做黑界头像网站成考过来人的忠告
  • 宁波网站建设是哪家便宜织梦网站数据库备份文件夹
  • 在北京大学生做家教的网站淘宝网页
  • 英铭网站建设网站如何推广引流
  • 关于电子商务网站建设的现状企业公示信息查询系统山西
  • 网站开发 翻译长春建站企业
  • dedecms网站网站解析一般什么时候
  • 制作网站的技术北京律师24小时电话
  • 可拖拽 网站建设如何做自媒体和网站签约赚点击
  • 做网站选哪个语言怎么登录百度app
  • 国发网站建设网站优化主要优化哪些地方
  • 快速微信网站开发定制网站建设费用预算
  • 网站制作叫什么知名网站建设制作
  • 网络营销网站建设公司h5应用
  • 网站开发合同要上印花税吗南江红鱼洞水库建设管理局网站
  • 疏通下水道网站怎么做wordpress 恢复初始化
  • 电脑商业网站怎的做软文推广渠道
  • 自己做网站需要买什么如何做微信商城网站
  • 有了网站开发app是不是更容易自建网站管理