Build.xml 无法发送电子邮件,给出“java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage";错误 [英] Build.xml is failing to send email, gives "java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage" error

查看:61
本文介绍了Build.xml 无法发送电子邮件,给出“java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage";错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是测试完成后运行的目标之一,buil.xml(通过或失败).此目标失败并给出错误java.lang.ClassNotFoundException:javax.mail.internet.MimeMessage".所以我展开了mail.1.4.jar 文件,看到这个类在那里.所以接下来我检查了这个 jar 是否在我的 setclasspath 目标中,它就在那里.第三件事,我检查了 mail.1.4.jar 是否包含在 ant 的路径中,它就在那里.现在我不明白为什么我会收到这个错误.

Below is one of the targets that runs after the completion of tests, buil.xml(pass or fail). This target is failing and giving error "java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage". So I expanded the mail.1.4.jar file and saw this class was there. So next I checked that this jar was there in my setclasspath target or not, and it was there. Third thing I checked that mail.1.4.jar was included in ant's path or not and it was there. Now I am not able to understand why I am getting this error.

<target name="sendmail">
    <mail from="[myname@company.com]"
    subject="Test Email" mailhost="smpt.gmail.com" 
    user="myusername" password="mypassword" message="This is a test email">
        <to name="receivers name" address="[receiver@gmail.com]" />
    </mail>
</target>

推荐答案

如果 Ant 给出java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage"错误,则表示缺少 jar.

If Ant gives the "java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage" error, it means there is a jar missing.

到findjar网站:http://www.findjar.com/,找到对应的jar 通过搜索javax.mail.internet.MimeMessage".你会发现它是mail.jar.

Go to the findjar website: http://www.findjar.com/, and find the corresponding jar by searching "javax.mail.internet.MimeMessage". You'll find it's mail.jar.

然后从中央Maven仓库下载jar文件:https://mvnrepository.com/artifact/javax.mail/mail,比如版本mail-1.4.7.jar,放在你的Ant lib目录下:${ANT_HOME}/lib

Then download the jar file from the central Maven repository: https://mvnrepository.com/artifact/javax.mail/mail, for example, version mail-1.4.7.jar, and put it in your Ant lib directory: ${ANT_HOME}/lib

应该可以.

这篇关于Build.xml 无法发送电子邮件,给出“java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆