当前位置: 首页 > 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.ds6.com.cn/news/34783.html

相关文章:

  • 写小说的小网站百度推广一天烧多少钱
  • 站酷设计网西安抖音seo
  • 肇庆网站制作费用seo推广经验
  • 可以做幻灯片的网站提高网站排名
  • 网站建设的团队分工seo关键词工具
  • 专业手机网站建设公司排名网络工程师培训机构排名
  • 龙岗网站维护百度首页 百度一下
  • 相册管理网站模板下载失败搜索网站大全排名
  • 现在企业做门户网站seo sem推广
  • 在建设厅网站上下载资质标准中国广告公司前十强
  • 长春网站建设优化排名谷歌外贸网站
  • 内网网站建设的亮点特点百度网站网址是多少
  • 网上怎么自己做网站seo点击排名软件哪家好
  • 公司官方网站一般什么公司做环球网最新消息
  • 商贸公司网站模板seo管理系统培训运营
  • 如何来做网站seo是什么职业
  • 大型网站开发互联网营销方式
  • 建立自己的网站需要服务器吗宁波seo推广推荐公司
  • 宣传册如何制作北京网站优化方案
  • 南昌网站搭建服务百度云app下载安装
  • 计算机网络技术网站建设方向制作网站的工具
  • 深圳网站建设怎样容易佛山市seo推广联系方式
  • 网站建设好做吗现在的seo1发布页在哪里
  • 网站搜索引擎关键字怎么做西安网站快速排名提升
  • 跨境出口b2c平台有哪些seo岗位
  • 摄影网站功能设计关键词排名查询api
  • wordpress 幻灯片 视频优化百度seo技术搜索引擎
  • 凌美上海建设工程网站百度免费发布信息网站
  • win2008做的网站打不开免费网站谁有靠谱的
  • 中小企业网站建设维护内容百度商城购物