simplejavamail : Batch module not found, make sure it is on the classpath

org.simplejavamail.internal.modules.ModuleLoaderException: Batch module not found, make sure it is on the classpath (https://github.com/bbottema/simple-java-mail/tree/develop/modules/batch-module)

今天使用simplejavamail发送邮件报错,只是把同步改为异步发送,然后就从代码入手看:

public final AsyncResponse sendMail(Email email, boolean async) {
        if (this.validate(email)) {
            SendMailClosure sendMailClosure = new SendMailClosure(this.operationalConfig, this.session, email, this.proxyServer, async, this.operationalConfig.isTransportModeLoggingOnly(), this.smtpConnectionCounter);
            if (!async) {
                sendMailClosure.run();
                return null;
            } else {
            // 如果是异步,这里去加载批处理模块了,但是我本地没有引入批处理模块代码
                return ModuleLoader.loadBatchModule().executeAsync(this.operationalConfig.getExecutorService(), "sendMail process", sendMailClosure);
            }
        } else {
            throw new AssertionError("Email not valid, but no MailException was thrown for it");
        }
    }

加入需要包

<dependency>
    <groupId>org.simplejavamail</groupId>
    <artifactId>simple-java-mail</artifactId>
    <version>6.0.3</version>
</dependency>

<dependency>
    <groupId>org.simplejavamail</groupId>
    <artifactId>batch-module</artifactId>
    <version>6.0.3</version>
</dependency>

在这里插入图片描述

posted @ 2020-03-03 16:28  慢慢行  阅读(41)  评论(0编辑  收藏  举报