Spring MimeMessageHelper构造函数映射?

时间:2012-02-04 10:14:52

标签: spring

如何使用构造函数实例化MimeMessageHelper。

MimeMessageHelper mimeMessageHelper2 = new MimeMessageHelper(mimeMessage, true);

我试过这个

<beans:bean id="mimeMessageHelper" class="org.springframework.mail.javamail.MimeMessageHelper">
        <beans:constructor-arg index = "0">
            <beans:ref bean="mimeMessage" />
        </beans:constructor-arg>
        <beans:constructor-arg index = "1" type = "java.lang.Boolean" value="true"/>

    </beans:bean> 

使用此配置spring无法实例化mimeMessageHelper

  

org.springframework.beans.factory.BeanCreationException:在类路径资源[web-application-config.xml]中定义名称为“mimeMessageHelper”的bean时出错:指定了2个构造函数参数但在bean“mimeMessageHelper”中找不到匹配的构造函数(提示:为简单参数指定索引和/或类型参数以避免类型歧义)

1 个答案:

答案 0 :(得分:0)

我现在不能测试这段代码,但是尝试为mimeMessage添加类型

<beans:constructor-arg index = "0" type="javax.mail.internet.MimeMessage">
  <beans:ref bean="mimeMessage" />
</beans:constructor-arg>