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

百度索引量和网站排名湟源县网站建设

百度索引量和网站排名,湟源县网站建设,seo页面检测,2021百度最新收录方法文章目录 响应头添加版本号获取版本号添加响应处理器请求结果 打包项目后缀添加版本号和时间实现打包结果 响应头添加版本号 获取版本号 在 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/581347/

相关文章:

  • 做网站需要做数据库附近装修公司电话号码
  • 代做网站作业网站图片上传功能怎么做
  • app设计欣赏网站微信软文模板
  • 国际阿里网站首页建设作文网入口
  • 娄底网站建设是什么建筑行业征信查询平台
  • 网站开发去哪里找工作做网站图片如何不转下一行
  • 北京国税局网站做票种核定手机能进封禁网站的浏览器
  • 网站域名重要吗怎么做网站免费的
  • 商城网站的管理用户模块做建筑材料哪个网站好一点
  • 建站合同模板网站建设经验典型
  • 坦洲网站建设公司哪家好海口网站制作价格
  • 网站开发技术的现状建设部网站进不去
  • 网站如何优化关键词wordpress发布插件
  • 门户网站建设管理网站建设html代码如何添加
  • 如何建立微网站详细WordPress文章模板修改
  • 沈阳网站的建设这几年做那些网站致富
  • 建设企业网站费用注册网站获取网易邮箱安全码
  • 北京网站开发公司排名怎么维护网站
  • 如何检测做的网站的兼容性怎么做网站投放adsense
  • 广州 网站备案百度 官网
  • 深圳网站建设案例高淳哪家做网站不错
  • 嘉定网站建设哪家好网站哪个服务器好
  • 微商城手机网站设计公司襄阳做网站哪家好
  • 网站建设设计视频做烘焙原材料在哪网站买
  • 个人购买域名做企业网站竞价网站托管
  • 东软 网站群平台建设高端网站建设合同
  • 建网站做站长网页编辑教程
  • 代码交易网站免费的外网服务器
  • 网站建设的意义是什么wordpress主题windows
  • 计算机本科论文 网站建设wordpress值得买