Spring boot 的 @Value注解读取配置文件中的00开头的字符串

Spring boot 的 @Value注解读取配置文件中的00开头的字符串:

代码如:

@Value("${spring.boot.bizType}")

private String bizType;

配置文件中如:

spring:
    boot:
        bizType: 0011

在项目启动后:

bizType的值变成了9

原因(我猜的,待确认):

  即框架将0011视为八进制的11后转为十进制9。

 

解决:

  修改代码为:

spring:
    boot:
        bizType: "0011"

 

posted on 2018-03-13 11:28  万水千山z  阅读(1954)  评论(0编辑  收藏  举报

导航