当前位置: 首页 > 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.yayakq.cn/news/778897/

相关文章:

  • 房产中介网站建设进度中建卓越建设有限公司网站首页
  • 博兴县城乡建设局网站工程施工合同协议书范本
  • 屋领网站固链机械做网站
  • 哪里做公司网站江山网站建设
  • 手机网站 栏目定制加快百度收录的方法
  • 南京网站设计哪家公司好建站网站关键词优化
  • 做网站设计需要什么技术h5在线设计平台
  • 辽宁省网站制作如何制作一个简单的网站
  • 对网站做数据统计的目的是什么意思建设网站步骤
  • 扁平化设计风格的网站模板免费下载广东手工活外发加工网
  • 建设门户网站需要注意什么意思海拉尔网站设计
  • 微软网站开发工具有哪些北京公司注册网站
  • 辽宁城市建设职业技术学院教务网站怎么自己开发网址
  • 佛山网站建设公司有哪些?如何搭建一个网站开发环境
  • 网站制作专业的公司移动网站建设报价表
  • 单位做网站注意什么奉贤广州网站建设
  • 中国建设银行网站首页公司注册一站式平台
  • 没有服务器怎么先做网站网络技术题库
  • 广州做公司网站的公司有哪些天津艺匠做网站
  • 建设工程有限公司起名重庆短视频seo优化推荐
  • 淘宝详情页做的比较好的网站中国行业数据分析网
  • 郑州网站建设哪家强注册公司需要交多少税
  • 能帮忙做网站建设网站域名推广
  • 网站做等保标准的网络推广计划书的目录
  • 南城网站建设多少钱湖南地税局官网站水利建设基金
  • 什么是网站组件网站设计规划书
  • 广西网站建设招标公司大连专业网站设计服务商
  • 优秀网站作品截图青海企业网站建设公司
  • 怎样建造网站wordpress-seo
  • 备案修改网站名称专门做网站网站犯法吗