Created
July 24, 2015 07:56
-
-
Save relax-more/6a7842648c2d00ed4598 to your computer and use it in GitHub Desktop.
[java] DI data to static field with spring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<beans | |
http://www.springframework.org/schema/beans/spring-beans.xsd" | |
> | |
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> | |
<property name="staticMethod" value="jp.co.myProject.MyClass.setStaticField" /> | |
<property name="arguments"> | |
<value>staticFieldValue</value> | |
</property> | |
</bean> | |
</beans> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Class MyClass{ | |
private static String staticFieldValue; | |
public static void setStaticField(String staticFieldValue){ | |
this.staticFieldValue = staticFieldValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment