Java Setting Static field with spring beans
<p>I have a spring boot project and I am trying to set some static constant variables from spring beans. Here are the relevant files</p>

<p><strong>application.properties</strong></p>

<pre><code>app.constants.name=FooTester
app.constants.version=v1
app.constants.port=123
</code></pre>

<p><strong>AppConfig.java</strong></p>

<pre><code>@Configuration
public class AppConfig {
    @Value("${app.constants.name}")
    private String appName;

    @Bean
    public MethodInvokingBean initAppConstants() {
        MethodInvokingBean miBean = new MethodInvokingBean();

        miBean.setStaticMethod("app.constants.AppConstants.setAppName");
        miBean.setArguments(new String[]{appName});
        try {
            miBean.prepare();
            miBean.invoke();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return miBean;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }
}
</code></pre>

<p><strong>AppConstants.java</strong></p>

<pre><code>public final class AppConstants {
    public static String APP_NAME;
    public static String APP_VERSION;
    public static String APP_PORT;

    private AppConstants(){}

    public static void setAppName(Properties p) {
        APP_NAME = p.toString();
    }
}
</code></pre>

<p>This gets the value of name fine but when it gets to the <code>setAppName</code> method, the properties value is a hashmap with the key as <code>FooTester</code> and value as <code>""</code>. If I added in multiple values with the <code>setArguments</code> method like so:</p>

<pre><code>miBean.setArguments(new String[]{"test", "test2", "test3"});
</code></pre>

<p>The properties object would only have 1 entry in the hashmap and the key would just be <code>test, test2, test3</code> and the value as <code>""</code>.</p>

<p>Additionally, I would like the constant values to be <code>final</code> rather than just <code>public static</code>. So I'm not sure that this is the right way to do it. How do I accomplish what I want?</p>