spring bean中注入属性文件中的值

spring bean中注入属性文件中的值

bean中

@Value("${email.toUsers}")
private String toUsers;
    

属性文件email.properties

[email protected],[email protected]

配置文件中

<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"> 
    <property name="locations">
        <list>
            <value>classpath:email.properties</value>
        </list>   
    </property> 
</bean>

猜你喜欢

转载自magicyang919.iteye.com/blog/2031890