cro*_*ies 3 java scala apache-commons
创建了一个简单的Apache Commons Email对象并进行编译.已导入:import org.apache.commons.mail._并且javax.mail.internet.MimeMessage还执行了以下操作:
def sendVerification(user: User) = {
val email = new SimpleEmail()
email.setHostName("smtp.sendgrid.net")
email.setSmtpPort(465)
email.setAuthenticator(new DefaultAuthenticator("user", "pass"))
email.setSSLOnConnect(true)
email.setFrom("Community Admin <admin@domain.com>")
email.setSubject("TestMail")
email.setMsg("""Welcome %s!
Thanks for signing up. This email is to confirm your email address.
Cheers,
Admin Team
""" format user.firstName)
email.addTo(user.email)
email.send()
}
Run Code Online (Sandbox Code Playgroud)
错误如下:
[error] C:\Users\path\to\AccountService\models\User.scala:43: object mail is not a member of package javax
[error] import javax.mail.internet.MimeMessage
[error] ^
[error] error while loading Email, Missing dependency 'class javax.mail.internet.MimeMessage', required by C:\Users\path\lib\commons-email-1.2.jar(org/apache/commons/mail/Email.class)
[error] C:\Users\path\com\threetierlogic\AccountService\models\User.scala:256: value setHostName is not a member of org.apache.commons.mail.SimpleEmail
[error] email.setHostName("smtp.sendgrid.net")
Run Code Online (Sandbox Code Playgroud)
但是,当我进行编译时,它会在每个调用的方法上抛出错误val email.这是一个与可变性有关的问题吗?或者版本有变化1.3吗?
梅尔尼科尔森指出了正确的问题,这与依赖没有被提取有关.我没有意识到它没有附带我下载的Apache JAR.所以我只是把它添加到我的sbt Build.scala和瞧!它汇编了.
val commonsMail = "org.apache.commons" % "commons-email" % "1.3"
| 归档时间: |
|
| 查看次数: |
1024 次 |
| 最近记录: |