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

internet网站建设试卷手机端的网站首页该怎么做

internet网站建设试卷,手机端的网站首页该怎么做,建设直播平台网站软件,外包建设网站服务现在很多开源的组件都会提供对应的 springboot-starter 包给我们去用#xff0c;要做一个 starter 包并不难。参照Spring内置的实现就好了#xff1a; 1、在工程里引入 starter 打包相关的依赖。 2、在我们工程内建 spring.factories 文件#xff0c;编写我们配置类的全限类… 现在很多开源的组件都会提供对应的 springboot-starter 包给我们去用要做一个 starter 包并不难。参照Spring内置的实现就好了 1、在工程里引入 starter 打包相关的依赖。 2、在我们工程内建 spring.factories 文件编写我们配置类的全限类名。 一、自定义步骤详解 使用AOP实现拦截方法执行和打印日志的功能 1.1、创建Starter项目 名称 zhinian-log-spring-boot-starter , 版本号是 1.0-SNAPSHOT 。且同时引入下方依赖。 1.2、引入pom依赖 ?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.zn.opit.base/groupIdartifactIdzhinian-log-spring-boot-starter/artifactIdversion1.0-SNAPSHOT/versionpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-configuration-processor/artifactIdversion2.7.13/versionoptionaltrue/optional/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-aop/artifactIdversion2.7.13/version/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdconfigurationclassifierexec/classifier/configuration/plugin/plugins/build/project1.3、定义Starter需要的配置类(Properties) package com.zn.opit.base.config;import org.springframework.boot.context.properties.ConfigurationProperties;ConfigurationProperties(prefix zn.log) public class ZhiNianLogProperties {private boolean enabled;public boolean isEnabled() {return enabled;}public void setEnabled(boolean enabled) {this.enabled enabled;} }如果我们需要从 application.yaml 或 application.properties 中拿到一些使用者配置的数据那么我们就需要定义一个properties类。这个properties类主要作用是将 application.yaml 或 application.properties 中的配置信息映射成实体类比如我们这里指定 prefix “zn.log” 这样我们就能将以zn.log为前缀的配置项拿到了。 1.4、编写Starter项目的业务功能 AOP切面逻辑 package com.zn.opit.base.component;import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component;Aspect Component public class WebLogAspect {Pointcut(execution(* *..*Controller.*(..)))public void webLog(){}Before(webLog())public void doBefore(JoinPoint joinPoint) throws Throwable {//方法开始前打印开始日志System.out.println(zn-starter --------doBefore);}AfterReturning(returning ret, pointcut webLog())public void doAfterReturning(Object ret) throws Throwable {// 处理完请求打印结束日志System.out.println(zn-starter --------doAfterReturning);} }1.5、编写自动配置类 package com.zn.opit.base.config;import com.zn.opit.base.component.WebLogAspect; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;Configuration // 表示该类是一个配置类 EnableConfigurationProperties({ZhiNianLogProperties.class}) // 该注解的作用是为 xxxProperties 开启属性配置功能并将这个类以组件的形式注入到容器中 ConditionalOnProperty(prefix zn.log, value enabled) // 当指定的配置项等于你想要的时候配置类生效 public class ZnLogAutoConfig {Bean // Bean该注解用于将方法的返回值以 Bean 对象的形式添加到容器中ConditionalOnMissingBean // ConditionalOnMissingBean(xxx.class)该注解表示当容器中没有 xxx 类时该方法才生效public WebLogAspect webLogAspect() {return new WebLogAspect();} }1.6、编写spring.factories文件加载自动配置类 org.springframework.boot.autoconfigure.EnableAutoConfigurationcom.zn.opit.base.config.ZnLogAutoConfig1.7、构建starter制品包 buildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdconfigurationclassifierexec/classifier/configuration/plugin/plugins /build在项目根目录下执行mvn clean install打包并放到maven仓库中(maven仓库地址和配置有关) 显示build success表示starter制品包打包完成 二、其它项目引用验证 2.1、pom中引入自定义starter依赖 ?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.zn.opit.base/groupIdartifactIdzhinian-log-starter-test/artifactIdversion1.0-SNAPSHOT/versionpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactIdversion2.7.13/version/dependencydependencygroupIdcom.zn.opit.base/groupIdartifactIdzhinian-log-spring-boot-starter/artifactIdversion1.0-SNAPSHOT/version/dependency/dependencies /project2.2、写一个Controller接口 (要符合starter里的aop拦截表达式规则否则拦截不到) package com.zn.opit.base.controller;import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RequestMapping(/hello) RestController public class HelloController {GetMapping(/test)public String test() {return SUCCESS;} }2.3、配置文件 application.properties zn.log.enabledtrue server.port80772.4、验证 启动业务项目访问接口验证 至此一个简单的starter示例就写完了。
http://www.pierceye.com/news/371486/

相关文章:

  • 比较简洁大方的网站伊春住房和城乡建设网站
  • 电商网站开发prd免费个人网页模板
  • 西安 网站开发 招聘响应式网站代理
  • 浙江建设干部学校网站免费wordpress搭建
  • 海尔网站建设内容策划wordpress 登录密码
  • 金融公司网站规划方案四川省住建厅特种作业证报名
  • 做网站员培训网站小视频怎么做
  • 做网站是学什么专业的电子商务网络营销方式
  • 东莞电商网站公司goz建站
  • 深圳石岩建网站权威发布李建
  • 大连哪家公司做网站比较好网页搜索的快捷键
  • 怎样建个小公司的网站濮阳网络电视直播
  • 台州低价网站建设阆中做网站
  • 兰州网站运营诊断学校网站报价方案
  • 宿迁做网站大公司现在企业做网站一般用什么框架
  • 企业如何建自己的网站自己网站的登录api怎么做
  • 专业的网站建设企业微信小程序服务器一年多少钱
  • 关于网站建设的句子苏州实力做网站公司有哪些
  • 网页制作与网站建设》在线作业 答案wordpress信息量几百万
  • 代刷网站系统怎么做wordpress数据库连接
  • 邢台网站改版开发开封美食网站建设规划
  • 网站建设佰金手指科杰二五国内网站推广
  • wordpress 多站点 用户天津经济持续恢复
  • 做网站邯郸怎样建立平台
  • 网站中捕获鼠标位置mip wordpress 评论
  • 室内设计资料网站discuz是什么东西
  • 网站建设方向论文提纲网页作品制作的一般过程
  • 生道网站建设平台高端商品网站
  • 网站维护计划商标注册号查询入口官网
  • 个人怎样申请网站网站整站html