【发布时间】:2017-03-09 14:02:37
【问题描述】:
我的 applicationContext.xml 文件中有以下配置:
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:application.properties</value>
<value>classpath:database.properties</value>
</list>
</property>
</bean>
<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${smtp.host}" />
</bean>
在我的 POM 文件中设置 smtp.host,如下所示:
<build>
<defaultGoal>install</defaultGoal>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<application.env>local</application.env>
<profile.scope>compile</profile.scope>
<skip.test>true</skip.test>
<smtp.host>my.smtp.server</smtp.host>
</properties>
</profile>
在部署我的应用程序时,我遇到了一条错误消息,指出 Spring 无法解析 smtp.host。我在 application.properties 文件中添加了以下映射:
smtp.host=${smtp.host}
但是 Spring 开始抱怨我在属性上有一个循环占位符引用。我有什么遗漏吗?
谢谢!
【问题讨论】: