
你可以在Spring 3中使用EL支持进行此 *** 作。例:
@Value("#{systemProperties.databaseName}")public void setDatabaseName(String dbName) { ... }@Value("#{strategyBean.databaseKeyGenerator}")public void setKeyGenerator(KeyGenerator kg) { ... }systemProperties是一个隐式对象,并且
strategyBean是Bean名称。
还有一个示例,当你想从
Properties对象中获取属性时,该示例将起作用。它还显示你可以应用于@Value字段:
@Value("#{myProperties['github.oauth.clientId']}")private String githubOauthClientId;欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)