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

代码如:

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

private String bizType;

配置文件中如:

spring:
    boot:
        bizType: 0011

在项目启动后:

bizType的值变成了9

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

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

 

解决:

  修改代码为:

spring:
    boot:
        bizType: "0011"

 

相关文章:

  • 2022-02-08
  • 2022-12-23
  • 2021-07-09
  • 2021-06-01
  • 2021-08-05
  • 2021-10-05
  • 2021-11-13
  • 2021-12-12
猜你喜欢
  • 2022-12-23
  • 2021-11-29
  • 2021-07-24
  • 2022-12-23
  • 2022-02-08
  • 2021-11-13
  • 2021-11-10
相关资源
相似解决方案