@PropertySource and UTF-8 properties file

前端 未结 6 621
广开言路
广开言路 2020-12-20 23:11

Is it possible, using @PropertySource annotation, to configure the encoding that has to be used to load the property file?

An example to clarify my prob

6条回答
  •  粉色の甜心
    2020-12-20 23:56

    Warm reminder:

    define @PropertySource with different features in other project classes can give you results that you're not expected.

    for example

    In Class A:

     @PropertySource(value = "classpath:/myprop.properties", encoding="UTF-8")
    

    While in Class B:

    @PropertySource(value = "classpath:/myprop.properties")
    

    Class B's annotation may override Class A's, and in this case Class A's encoding is voided.

提交回复
热议问题