在您的
Utility课程中,您可以使用setter方法来设置属性,然后可以使用
MethdInvokingFactoryBean。
class Utility{ static String username; static String password; public static setUserNameAndPassword(String username, String password){ Utility.username = username; Utility.password = password; } //other stuff}<bean > <property name="locations"> <list> <value>classpath*:/myservice_detaults.properties</value> <value>classpath*:/log4j.properties</value> </list> </property></bean><bean > <property name="staticMethod" value="foo.bar.Utility.setUserNameAndPassword"/> <property name="arguments"> <list> <value>${username}</value> <value>${password}</value> </list> </property></bean>


