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

关于网站建设的意义设计师公司排名

关于网站建设的意义,设计师公司排名,机关单位网站管理部门应建立,html字体代码大全文章目录 响应头添加版本号获取版本号添加响应处理器请求结果 打包项目后缀添加版本号和时间实现打包结果 响应头添加版本号 获取版本号 在 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/182352/

相关文章:

  • 优质的南昌网站建设长沙网站收录
  • 本地网站有什么可以做嵌入式软件开发是干嘛的
  • 旅游网站建设的概念视频直播软件开发
  • 秋实网站建设自有服务器可以做网站吗
  • 天津网站建设网络营销策略应遵循的原则
  • 群辉做网站服务器配置做网站简单需要什么
  • 网站开发工程师前景网站建设动态
  • 怎么制作个人求职网站做泥网站
  • 做网站需要准备哪些东西安贞街道网站建设
  • 网站设计的特点电子商务网站建设方
  • 怎样能让百度搜到自己的网站大连python培训
  • 全媒体门户网站建设方案百度智能云官网
  • 0基础学网站设计网络公司名字大全简单好听
  • 企业网站目的黄骅港信息贴吧
  • 中国嘉兴门户网站企业网站源码下载站长之家
  • 网站设计专业廊坊百度seo公司
  • 西安千度网站建设廊坊seo
  • 个人网站备案麻烦吗网站分站系
  • 做国外网站翻译中国小说赚钱wordpress 关键词设置
  • 淘宝客自己做网站吗新网域名转出
  • 网站开发摘要企业关键词排名优化网址
  • 长沙专业做网站排名江门网站建设自助建站
  • 外贸站群wordpress主题改字体
  • 全网vip视频网站怎么做asp.net 4.0网站开发实例教程
  • 建设网站广告语公众号和网站先做哪个
  • 基金会网站建设怎么制作微信公众号文章
  • 山东网站建站系统平台wordpress 主题 ie8
  • 重庆南川网站制作公司哪家专业企业网站优化排名
  • 口碑最好的网站建设元谋网站建设
  • 网站建设企业建站模板长沙经开区建设局网站