如何在属性文件的数值中包含 _ ?

Mah*_*zad 4 java spring readability properties el

在 Spring 中_使用注释注入时,如何在我的数字属性中包含(下划线)?@Value如果我将其包含_在我的值中,Spring 会抛出TypeMismatchException.

.properties 文件:

min-score=20_000
Run Code Online (Sandbox Code Playgroud)

java类:

@Value("${min-score}")
private int minScore;
Run Code Online (Sandbox Code Playgroud)

Mah*_*zad 5

在注释中使用 Spring EL@Value来替换_字符:

@Value("#{'${min-score}'.replace('_','')}")
private int minScore;
Run Code Online (Sandbox Code Playgroud)