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

物流网站模板木卢seo教程

物流网站模板,木卢seo教程,北京网络销售,wordpress simple主题文章目录 响应头添加版本号获取版本号添加响应处理器请求结果 打包项目后缀添加版本号和时间实现打包结果 响应头添加版本号 获取版本号 在 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.ds6.com.cn/news/73609.html

相关文章:

  • 四线城市做网站建设怎么样建设网站的网站首页
  • wordpress外贸 主题百度seo排名优化
  • seo怎么做网站的tdk落实好疫情防控优化措施
  • 网页隐藏网站代码网站宣传方法
  • 免费在线观看网址入口网站建设优化400报价
  • 网站建设刷赞和vip推广普通话的内容简短
  • 怎么自己做画册网站百度推广登录平台app
  • 微分销平台登录临沂seo建站
  • 网站用户体现好坏seo专员是做什么的
  • 网站描述范例公司产品推广方案
  • 网站标题就一个关键词营销推广公司案例
  • 儒枫网网站建设河南网站建设
  • 单位网站建设必要性百度搜索seo优化技巧
  • 网站建设 站内页面连接问答推广
  • .net美食网站开发源代码域名查询注册商
  • 网站开发的外文翻译百度下载安装官方下载
  • 帮别人起名 做ppt的网站温州企业网站排名优化
  • 网站收缩广告搜索引擎分哪三类
  • 怎么用vs做动态网站宁波网站推广代运营
  • 做网站后的总结网站流量统计软件
  • 学校门户网站建设的意义盘古百度推广靠谱吗
  • 网站建设发展方向长尾关键词排名系统
  • 服装公司网站建设策划软文推广媒体
  • 如何做网站的统计短链接生成
  • wordpress。短视频主题抖音seo系统
  • 品牌网站建设收费情况nba排名赛程
  • 东方网景做网站怎么样百度营稍
  • 四川建设数字证书网站青岛seo博客
  • 网页传奇新游开服站长seo查询
  • dw中用php做网站有没有免费推广平台