Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 32 章 Spring boot with Git version

目录

32.1. CommonRestController 公共控制器
32.2. VersionRestController 测试控制器
32.3. 创建 .gitattributes 文件

Spring boot 每次升级打包发给运维操作,常常运维操作不当致使升级失败,开发怎样确认线上的jar/war包与升级包一致呢?

请看下面的解决方案

32.1. CommonRestController 公共控制器

所有 RestController将会集成 CommonRestController

        
package cn.netkiller.api.rest;

import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;

public class CommonRestController {

@RequestMapping("ping")
@ResponseStatus(HttpStatus.OK)
public String welcome() {
    return "PONG";
}

@RequestMapping("commit")
public String commit() {
    return "$Id$";
}

@RequestMapping("auth")
@ResponseStatus(HttpStatus.OK)
public String auth(@AuthenticationPrincipal final UserDetails user) {
    return String.format("%s: %s %s", user.getUsername(), user.getPassword(), user.getAuthorities());
}
}