Bilan-application-context.xml
:
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${spring.mail.host}"/>
<property name="port" value="${spring.mail.port}"/>
<!-- <property name="username" value="howtodoinjava@gmail.com"/>
<property name="password" value="password"/> -->
<property name="javaMailProperties">
<props>
<prop key="mail.transport.protocol">${mail.transport.protocol}</prop>
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
<prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable}</prop>
<prop key="mail.debug">${mail.debug}</prop>
</props>
</property>
</bean>
错误是:
org.springframework.beans.factory.BeanDefinitionStoreException:
Invalid bean definition with name 'mailSender' defined in class path resource
[bilan-application-context.xml]: Could not resolve placeholder 'spring.mail.host' in value "${spring.mail.host}";
nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.mail.host' in value "${spring.mail.host}"
我找不到上述解决方案。
答案 0 :(得分:0)
您将Bilan-application-context.xml
内部的属性文件显示为:
<context:property-placeholder location="classpath:spring/mail.properties"/>
mail.properties
,您需要确保根据属性将其更改为适当的路径和正确的文件名。