Spring @Value annotation always evaluating as null?

前端 未结 6 1157
别跟我提以往
别跟我提以往 2020-12-05 09:33

So, I have a simple properties file with the following entries:

my.value=123
another.value=hello world

This properties file is being loaded

6条回答
  •  春和景丽
    2020-12-05 10:13

    See my answer here.

    I ran into the same symptoms (@Value-annotated fields being null) but with a different underlying issue:

    import com.google.api.client.util.Value;

    Ensure that you are importing the correct @Value annotation class! Especially with the convenience of IDEs nowadays, this is a VERY easy mistake to make (I am using IntelliJ, and if you auto-import too quickly without reading WHAT you are auto-importing, you might waste a few hours like I did).

提交回复
热议问题