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
问题描述
以下是测试完成后运行的目标之一,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/,然后找到相应的通过搜索"javax.mail.internet.MimeMessage"创建jar.您会发现它是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屋!