加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 为什么来自Play项目中的sbt-docker的enablePlugins(Do

发布时间:2020-12-16 03:44:24 所属栏目:安全 来源:网络整理
导读:我试图将一个播放网络应用程序停靠,我正在使用sbt-docker.当我执行sbt docker时,我得到了错误的错误: error: reference to DockerPlugin is ambiguous;it is imported twice in the same scope byimport _root_.sbtdocker.DockerPluginand import _root_.co

我试图将一个播放网络应用程序停靠,我正在使用sbt-docker.当我执行sbt docker时,我得到了错误的错误:

error: reference to DockerPlugin is ambiguous;
it is imported twice in the same scope by
import _root_.sbtdocker.DockerPlugin
and import _root_.com.typesafe.sbt.packager.docker.DockerPlugin
enablePlugins(DockerPlugin)
              ^
[error] Type error in expression
Project loading failed: (r)etry,(q)uit,(l)ast,or (i)gnore? q

我得到上面的错误,我的build.sbt看起来像这样:

enablePlugins(DockerPlugin)

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

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  jdbc,cache,ws,specs2 % Test
)

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

// Play provides two styles of routers,one expects its actions to be injected,the
// other,legacy style,accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

// Make docker depend on the package task,which generates a jar file of the application code
docker <<= docker.dependsOn(sbt.Keys.`package`.in(Compile,packageBin))

// Define a Dockerfile
dockerfile in docker := {
  val jarFile = artifactPath.in(Compile,packageBin).value
  val classpath = (managedClasspath in Compile).value
  val mainclass = mainClass.in(Compile,packageBin).value.getOrElse(sys.error("Expected exactly one main class"))
  val jarTarget = s"/app/${jarFile.getName}"
  // Make a colon separated classpath with the JAR file
  val classpathString = classpath.files.map("/app/" + _.getName).mkString(":") + ":" + jarTarget
  new Dockerfile {
    // Base image
    from("java")
    // Add all files on the classpath
    add(classpath.files,"/app/")
    // Add the JAR file
    add(jarFile,jarTarget)
    // On launch run Java with the classpath and the main class
    entryPoint("java","-cp",classpathString,mainclass)
  }
}

我怀疑是sbt-native-packager与sbt-docker冲突.但我不是在任何地方导入sbt-native-packager.

正如消息所说“并导入_root_.com.typesafe.sbt.packager.docker.DockerPlugin”sbt-native-packager附带了冲突的DockerPlugin类.但这就是你所知道的.

诀窍在于Play插件依赖于sbt-native-packager来缓解人们的生活,从而缓解冲突(对不起,过多的帮助可能会破坏人们的生命:)).

解决方案是使用完全限定的插件类名称@pfn recommended或disablePlugins(SbtNativePackager).

见http://www.scala-sbt.org/sbt-native-packager/topics/play.html.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读