spring注入字符串

application.properties文件中

spring.datasource.dialect=oracle

spring配置文件中

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:application.properties</value>
</property>
</bean>

<bean class="java.lang.String" id="dialect">
        <constructor-arg type="java.lang.String" value="${spring.datasource.dialect}"/>
</bean>

具体类中加载

@Resource
private String dialect;

即可注入







猜你喜欢

转载自blog.csdn.net/qq_23490959/article/details/79160101