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

网站开发培训机构湖南正规关键词优化报价

网站开发培训机构,湖南正规关键词优化报价,建企业网站的步骤,汉中疫情最新消息今天封城文章目录 响应头添加版本号获取版本号添加响应处理器请求结果 打包项目后缀添加版本号和时间实现打包结果 响应头添加版本号 获取版本号 在 pom.xml 中,在 project.version 下定义版本号 在 application.yml 获取 pom.xml 中 project.version 中的信息 添加响应处…

文章目录

  • 响应头添加版本号
    • 获取版本号
    • 添加响应处理器
    • 请求结果
  • 打包项目后缀添加版本号和时间
    • 实现
    • 打包结果


响应头添加版本号

获取版本号

pom.xml 中,在 project.version 下定义版本号

在这里插入图片描述

application.yml 获取 pom.xmlproject.version 中的信息

在这里插入图片描述

添加响应处理器

完整代码如下:

通过 @Value("${project.version}") 获取 application.yml 中的 project.version,并写入响应头

import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;@ControllerAdvice
public class GlobalResponseBodyHandler implements ResponseBodyAdvice<Object> {@Value("${project.version}")private String version;@Overridepublic boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {return true;}@Overridepublic Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {ServletServerHttpResponse ssResp = (ServletServerHttpResponse) response;HttpServletResponse resp = ssResp.getServletResponse();resp.setHeader("version", StringUtils.isNotEmpty(version) ? version : "unknown");return body;}
}

请求结果

在这里插入图片描述

打包项目后缀添加版本号和时间

实现

pom.xml 中的 build 标签,写入以下代码

<build><!--打包后生成文件名--><finalName>${project.artifactId}-${project.version}_${current.time}</finalName><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass>com.chh.api.ChhApplication</mainClass><executable>true</executable></configuration></plugin><plugin><groupId>org.codehaus.mojo</groupId><artifactId>build-helper-maven-plugin</artifactId><version>3.0.0</version><executions><execution><id>timestamp-property</id><goals><goal>timestamp-property</goal></goals></execution></executions><configuration><name>current.time</name><pattern>yyyyMMdd-HHmmss</pattern><timeZone>GMT+8</timeZone></configuration></plugin><!-- 打包跳过测试--><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><configuration><skip>true</skip></configuration></plugin></plugins>
</build>

打包结果

在这里插入图片描述

http://www.tj-hxxt.cn/news/57563.html

相关文章:

  • office做网站的软件seo外链发布工具
  • 天津企业网站广东广州重大新闻
  • wordpress 手动缩略图登封seo公司
  • 安庆商城网站开发seo常用的工具
  • wordpress无法上传文件seo站内优化
  • 上海医疗 网站制作信阳网站推广公司
  • 为什么不能安装wordpress海南seo代理加盟供应商
  • 建立网站的相关信息seo推广怎么做视频教程
  • 网站的开发和建设有什么区别百度广告推广怎么收费
  • eclipse tomcat 网站开发网站seo关键词优化
  • 软件开发项目优化技术基础
  • ui做自适应网站seo公司排行
  • 中国建设银行行号查询网站友情链接英文
  • 用php做的网站怎么上传查询网官网
  • 上海网站建设方法深圳华强北最新消息
  • 北京做网站网络公司举三个成功的新媒体营销案例
  • 网站建设中主页指的是如何自己做网站
  • 有没有专门做线下活动的网站软文范文
  • 展示型网站模板代码google搜索引擎官网
  • 专业的企业网站开发公司做推广的软件有哪些
  • 手机在线做网站数字营销案例
  • 做网站需要的条件郑州做网站推广哪家好
  • 网站展示怎么做网站优化企业排名
  • 创建免费论坛的10个网站竞价推广运营
  • 进出口外贸公司拼多多关键词怎么优化
  • 网站自己怎么做优化免费推广的渠道有哪些
  • dw建网站怎么做爱战网关键词工具
  • a0000网站建设东莞疫情最新通告
  • 网站分享图片怎么做武汉seo引擎优化
  • 怎么取网页视频网站元素seo 工具推荐