使用邮件和激活JAR在外部位置蚂蚁邮件任务 [英] ant mail task using mail and activation jar in external location

查看:221
本文介绍了使用邮件和激活JAR在外部位置蚂蚁邮件任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的蚂蚁邮件的任务 -

 <目标名称=sendtestreport>
    <邮件邮件主机=smtp.commailport =1025主题=测试版本>
        <从地址=test@gmail.com/>
        <的ReplyTo地址=test@gmail.com/>
        <解决=test@gmail.com/>
        <&消息GT;测试消息< /消息>
        <&附件GT;
        < /附件>
    < /邮件>
< /目标与GT;

和我有我的项目LIB文件夹中既激活和邮件罐子。我希望能够与具有保持这些罐子蚂蚁下载位置进行发送邮件。是否有可能让蚂蚁知道我的LIB文件夹以查看javaxmail和激活罐子。有些事情就像如果我能够从这个目标指定类路径。

现在,当我执行这个目标,我总是遇到例外 -

 构建失败
java.lang.ClassNotFound
例外:的javax.mail.internet.MimeMessage


解决方案

Unforunately你不能。
你必须把库依赖到类路径蚂蚁莫名其妙。

这可能是ANTH_HOME / lib目录或更改了命令行参数。

Ant有一个命令行参数来指定lib目录:

  -lib<路径>指定路径来搜索罐子和类

您也可以打电话从蚂蚁蚂蚁本身与信息,这可能是一个有点难看:

 < EXEC可执行=蚁族>
  < ARG值= - LIB/>
  < ARG值=PATH_TO_MY_LIB/>
  < ARG值=目标/>
< / EXEC>

如果您从Eclipse中执行此任务,您可以将库与其他开发人员添加到任务的运行定义和共享此运行的定义。

I have following ant mail task -

<target name="sendtestreport" > 
    <mail mailhost="smtp.com" mailport="1025" subject="Test build" >
        <from address="test@gmail.com" />           
        <replyto address="test@gmail.com" />
        <to address="test@gmail.com" />
        <message>test message</message>
        <attachments>
        </attachments>
    </mail>
</target>

And I have both activation and mail jar available in my project "lib" folder. I want to be able to send mail with out having to keep these jars in ant download location. Is it possible to let ant know about my "lib" folder to see javaxmail and activation jars. Some thing like If I could specify class path from with in this target.

Right now when I execute this target I always encounter exception -

BUILD FAILED
java.lang.ClassNotFound
Exception: javax.mail.internet.MimeMessage

解决方案

Unforunately you can't. You have to put Library Dependencies into the ant classpath somehow.

This could be the ANTH_HOME/lib dir or a change to the command line arguments.

Ant has a command-line argument to specify a lib dir:

-lib <path> specifies a path to search for jars and classes

You could also call ant from ant itself with that info, which may be a bit ugly:

<exec executable="ant">
  <arg value="-lib"/>
  <arg value="PATH_TO_MY_LIB"/>
  <arg value="target"/>
</exec>

If you execute this task from eclipse, you can add the libs to the run definition of the task and share this run definition with other developers.

这篇关于使用邮件和激活JAR在外部位置蚂蚁邮件任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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