如何在 Play 2.3 和 Scala 2.11 中使用 play-plugins-mailer? [英] How to use play-plugins-mailer with Play 2.3 and Scala 2.11?
问题描述
我正在尝试使用播放插件发送电子邮件:
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)?
但是我得到一个编译错误:
but I get a compilation error:
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
中有:
In the build.sbt
of the sample app there is:
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屋!