spring - read property value from properties file in static field of class

后端 未结 6 1127
一向
一向 2021-02-06 12:07

I have one utility class where i have one method which requires username and password to connect other url. I need to kept that username in properties file so that i can change

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-06 12:58

    Or using the @Value over the non-static setter method for username eg.

    @Value("${app.username}")
    public void setUserName(String userName) {
        UtilityClass.userName = userName;
    }
    

提交回复
热议问题