侧边栏壁纸
博主头像
进一步,海阔天空 博主等级

进一步,海阔天空

  • 累计撰写 140 篇文章
  • 累计创建 19 个标签
  • 累计收到 7 条评论

目 录CONTENT

文章目录

Springboot Gradle项目中获得应用版本号的方法

海阔天空
2022-05-28 / 0 评论 / 0 点赞 / 179 阅读 / 0 字

修改build.gradle文件

加入如下配置

springBoot {
    buildInfo()
}

在Controller中获得版本号即可

@Controller
public class IndexController {
    @Autowired
    private BuildProperties buildProperties;

    @RequestMapping({"/"})
    public ModelAndView index() {
        return new ModelAndView("index")
                .addObject("version", buildProperties.getVersion());
    }
}
0

评论区