message.properties
my.hello=hello
my.hello-world=${my.hello} world! (it doesn't work)
有没有办法在messages.properties中使用eval表达式?
答案 0 :(得分:1)
如果您扩展PropertySourcesPlaceholderConfigurer
并且在loadProperties
方法中,您可以对那些其值包含占位符前缀和后缀
答案 1 :(得分:0)
因为我找不到内置实现。我写了一个库Nest-Message-Spring-Boot
hello.guy=Hello {0}!
hello.world=$(hello.guy,world)
hello.world
将为Hello World!
hello.two=Hello {0} and {1}!
hello.owt=$(hello.two,$1,$0)
带有hello.world
的 {a, b}
将为Hello b and a!
book.name=<{0}>
book.price=\${0,number,#.#}
book.promote=Come to buy {0} with $(book.price,$1)
java.promote=Hello guys! $(book.promote,$(book.name,java)"(2nd edition)",{0})
java.promote
{123}
将{。} {
Hello guys! Come to buy <java>(2nd edition) with $123