如何在Play 2.3和Scala 2.11中使用play-plugins-mailer? [英] How to use play-plugins-mailer with Play 2.3 and Scala 2.11?

查看:199
本文介绍了如何在Play 2.3和Scala 2.11中使用play-plugins-mailer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用play插件发送电子邮件:

I am trying to use the play plugin for sending emails:

https://github.com/playframework/play-mailer

我已经按照github上的说明进行操作:将依赖项添加到build.sbt,使用指定的内容创建了play.plugins(我是否需要以某种方式注册文件)?

I have followed the instructions as found on github: added the dependency to build.sbt, created play.plugins with the specified content (do I need to register the file somehow)?

但出现编译错误:

object mailer is not a member of package play.api.libs

尝试导入时

import play.api.libs.mailer._

我在

val mail = use[MailerPlugin].email

找不到MailerPlugin和使用.

MailerPlugin and use are not found.

如何使它工作?

注意:该插件已正确下载(我可以在我的.ivy2目录中找到它),但是在我的应用程序中未将其列为依赖项.

Note: the plugin is correctly downloaded (I can find it in my .ivy2 directory), but it is not listed as a dependency in my application.

我的build.sbt文件:

My build.sbt file:

name := ...

version := "1.0-SNAPSHOT"

scalaVersion := "2.11.2"

resolvers += Resolver.typesafeRepo("releases")

//"mysql" % "mysql-connector-java" % "5.1.31"
libraryDependencies ++= Seq(
  "mysql" % "mysql-connector-java" % "5.1.24",
  "org.webjars" %% "webjars-play" % "2.3.0-2",
  "com.typesafe.play" %% "play-slick" % "0.8.0",
  "com.typesafe.play.plugins" %% "play-plugins-mailer" % "2.3.1",
  "org.mindrot" % "jbcrypt" % "0.3m"
)

fork in Test := false

lazy val root = (project in file(".")).enablePlugins(PlayScala)

我的play.plugins仅包含:

And my play.plugins contains only:

1500:com.typesafe.plugin.CommonsMailerPlugin

更新: 我已经从> https://github.com/playframework/play-mailer 下载了示例项目. 并尝试使用sbt进行编译.失败的原因完全相同.

UPDATE: I've downloaded the sample project from https://github.com/playframework/play-mailer and tried to compile using sbt. It failed with exactly the same problem.

推荐答案

在类型安全存储库中可用的插件版本似乎存在问题:

It looks like the problem is somehow with the version of plugin that is available in the typesafe repo:

我已经从源代码构建了插件,然后将其发布到本地存储库中,然后一切正常编译.

I've built the plugin from sources, published it to my local repository and then everything compiled fine.

示例应用程序的build.sbt中有:

resolvers += Resolver.file("LocalIvy", file(Path.userHome + File.separator + ".ivy2" + File.separator + "local"))(Resolver.ivyStylePatterns)

因此,看来作者在使用部署到官方存储库的插件来编译应用程序时也遇到了问题.

So it looks like the authors also had problems in compiling the app using the plugin deployed to the official repository.

更新: 好了,它编译正常,但随后在运行时失败,显示java.lang.ClassNotFoundException: com.typesafe.plugin.CommonsMailerPlugin

UPDATE: Well, it compiled fine, but then failed at runtime with java.lang.ClassNotFoundException: com.typesafe.plugin.CommonsMailerPlugin

更新2: 示例play.plugins也是错误的,正确的应该是:

UPDATE 2: The sample play.plugins is also wrong, the correct one should be:

1500:play.api.libs.mailer.CommonsMailerPlugin

然后一切都是正常的

这篇关于如何在Play 2.3和Scala 2.11中使用play-plugins-mailer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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