Nest Message Spring Boot
Reduce duplicate string in message source.
- If you are using
@EnableAutoConfiguration
, just add the dependency:
<dependency>
<groupId>com.github.XDean</groupId>
<artifactId>nest-message-spring-boot-starter</artifactId>
<version>x.x</version>
</dependency>
- If you are not using
@EnableAutoConfiguration
, add the dependency:
<dependency>
<groupId>com.github.XDean</groupId>
<artifactId>nest-message-spring-boot</artifactId>
<version>x.x</version>
</dependency>
and add @EnableNestMessageSource
on your configuration class:
@Configuration
@EnableNestMessageSource
public class MyApplication{
...
}
hello.guy=Hello {0}!
hello.world=$(hello.guy,world)
hello.world
will be Hello World!
hello.two=Hello {0} and {1}!
hello.owt=$(hello.two,$1,$0)
hello.world
with {a, b}
will be 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
with {123}
will be
Hello guys! Come to buy <java>(2nd edition) with $123
Properties prefix is xdean.message.nest
Property | Description | Effect out of expression | Default Value |
---|---|---|---|
prefix |
start a nest message expression | true | $( |
suffix |
end a nest message expression | false | ) |
splitor |
splitor in nest message expression | false | , |
escaper |
escaper in nest message expression | true | \ |
quoter |
quoter in nest message expression | false | " |
argPrefix |
argument placeholder prefix in nest message expression | false | $ |