gpt4 book ai didi

java - 上下文初始化失败 - Broadleaf Commerce - 发送订单确认电子邮件

转载 作者:行者123 更新时间:2023-12-01 13:15:23 28 4
gpt4 key购买 nike

在阔叶演示网站上,订购后我看到了..

A confirmation email has been sent to xyz@abc.com

但是电子邮件似乎没有发送,因为它尚未配置。我尝试对我的 applicationContext-email.xml 文件进行这些更改。

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">



<!-- A dummy mail sender has been set to send emails for testing purposes only
To view the emails sent use "DevNull SMTP" (download separately) with the following setting:
Port: 30000 -->
<bean id="blMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host"><value>smtp.mandrillapp.com</value></property>
<property name="port"><value>900</value></property>
<property name="protocol"><value>smtp</value></property>
<property name="username"><value>xyz@abc.com</value></property>
<property name="password"><value>mypassword</value></property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.smtp.timeout">25000</prop>
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
</bean>

<bean id="blEmailTemplateResolver" class="org.thymeleaf.templateresolver.ClassLoaderTemplateResolver">
<property name="prefix" value="emailTemplates/" />
<property name="suffix" value=".html" />
<property name="cacheable" value="${cache.page.templates}"/>
<property name="cacheTTLMs" value="${cache.page.templates.ttl}" />
</bean>

<bean id="blEmailTemplateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="templateResolvers">
<set>
<ref bean="blEmailTemplateResolver" />
</set>
</property>
<property name="dialects">
<set>
<bean class="org.thymeleaf.spring3.dialect.SpringStandardDialect" />
<ref bean="blDialect" />
</set>
</property>
</bean>

<bean id="blMessageCreator" class="org.broadleafcommerce.common.email.service.message.ThymeleafMessageCreator">
<constructor-arg ref="blEmailTemplateEngine"/>
<constructor-arg ref="blMailSender"/>
</bean>

<bean id="blMessageCreator" class="org.broadleafcommerce.common.email.service.message.NullMessageCreator">
<constructor-arg ref="blMailSender"/>
</bean>

<bean id="blEmailInfo" class="org.broadleafcommerce.common.email.service.info.EmailInfo">
<property name="fromAddress"><value>support@mycompany.com</value></property>
<property name="sendAsyncPriority"><value>2</value></property>
<property name="sendEmailReliableAsync"><value>false</value></property>
</bean>

<bean id="blRegistrationEmailInfo" parent="blEmailInfo">
<property name="subject" value="You have successfully registered!"/>
<property name="emailTemplate" value="register-email"/>
</bean>

<bean id="blForgotPasswordEmailInfo" parent="blEmailInfo">
<property name="subject" value="Reset password request"/>
<property name="emailTemplate" value="resetPassword-email"/>
</bean>

<bean id="blOrderConfirmationEmailInfo" parent="blEmailInfo">
<property name="subject" value="Your order with The Heat Clinic"/>
<property name="emailTemplate" value="orderConfirmation-email"/>
</bean>

</beans>

我还看到了一个名为 SendOrderConfirmationEmailActivity 类。这个类似乎发送电子邮件。这在 applicationContext-workflow.xml 的 Activity 中列出,但我收到以下异常。

[ERROR] 00:07:19 ContextLoader - Context initialization failed
[artifact:mvn] org.springframework.beans.FatalBeanException: Unable to merge source and patch locations; nested exception is org.broadleafcommerce.common.extensibility.context.merge.exceptions.MergeException: java.lang.NullPointerException
[artifact:mvn] at org.broadleafcommerce.common.extensibility.context.MergeApplicationContextXmlConfigResource.getConfigResources(MergeApplicationContextXmlConfigResource.java:86)
[artifact:mvn] at org.broadleafcommerce.common.web.extensibility.MergeXmlWebApplicationContext.loadBeanDefinitions(MergeXmlWebApplicationContext.java:130)
[artifact:mvn] at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)

您能告诉我如何发送订单确认电子邮件吗?

我正在使用Broadleaf commerce demo 3.1.0-GA版本。

最佳答案

您似乎定义了两个 blMessageCreator bean,第二个是 NullMessageCreator。我会从您的配置中删除后者,然后重试。

我的配置或多或少与您的相同,只是仅定义了 ThymeleafMessageCreator。我通过添加第二个 blMessageCreator 定义重现了您的问题。

您还提到看到 SendOrderConfirmationEmailActivity 类。请务必检查您是否有 SendOrderConfirmationEmailActivity 的实现(如果您没有从最近的 DemoSite 版本派生)。您需要提供此信息以将其链接到您在 applicationContext-workflow.xml 中覆盖的 blCheckoutWorkflow 中。我相信您可以在DemoSite应用程序here中找到演示实现.

希望这能让你继续前进。

关于java - 上下文初始化失败 - Broadleaf Commerce - 发送订单确认电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22515275/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com