无法找到 play.filters 包
Not able to find play.filters package
如 this 页面所述,我在我的播放框架应用程序中添加了过滤器的依赖项,但是在清理 - 重建时,我的项目仍然无法检测到 play.filters... 包它会导致编译错误。
我是不是漏掉了一些非常基本的东西?
"clean - rebuild" - 你在使用 Eclipse 吗?
如果是,则将 eclipse 插件添加到播放中(在 plugins.sbt
文件中):
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")
然后添加到build.sbt
下设置:
// Eclipse settings
// Compile the project before generating Eclipse files,
// so that generated .scala or .class files for views and routes are present
EclipseKeys.preTasks := Seq(compile in Compile)
// Java project. Don't expect Scala IDE
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java
// Use .class files instead of generated .scala files for views and routes
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)
// End of eclipse settings
然后运行activator eclipse
过滤器库也发生了这种情况,特别是 "com.typesafe.play" % "filters-helpers_2.11" % "2.4.2"
依赖项。
它应该可以从 Maven2 repo and the Typesafe Releases repo. Both of which are implicitly included in SBT's build.sbt file since they are predefined repos in SBT.
我的公司用 SSL 证书做各种奇怪的事情(他们基本上是重新签名)。对于我的情况,我认为真正的问题是激活器不信任证书,因为公司 proxy/firewall 搞砸了它。我能够通过告诉激活器不要使用 JVM 参数检查证书是否受信任来修复它。
要进入禁用证书检查的激活器 shell,只需键入:
activator -Dcom.sun.net.ssl.checkRevocation=false
然后您可以像往常一样 compile
或 run
并且 activator/SBT 应该下载依赖项,即使它们不是通过受信任的连接。
注意:我很少这样做是为了将麻烦的依赖项下载到我的本地缓存中。 运行 没有证书检查的激活器有点不安全,因为下载不受信任的依赖项可能会让您面临 trojan/MITM 攻击。
似乎是导入错误。我在 Eclipse 中为导入做了一个自动安排,它从我的 Java class:
中删除了以下导入语句
进口play.filters.cors.CORSFilter
由于不存在导入,即使 Activator 在构建时下载依赖项,它也无法找到 CORSFilter class,因为 Eclipse 在安排导入时删除了它。我再次添加了导入,虽然它在 Eclipse 中给出了 play.filters.cors 包未找到的错误,但正如预期的那样,它在构建时工作正常。
这看起来像是一个愚蠢的错误,但很难找到,所以如果以后有人遇到同样的问题,请在这里分享。
如 this 页面所述,我在我的播放框架应用程序中添加了过滤器的依赖项,但是在清理 - 重建时,我的项目仍然无法检测到 play.filters... 包它会导致编译错误。
我是不是漏掉了一些非常基本的东西?
"clean - rebuild" - 你在使用 Eclipse 吗?
如果是,则将 eclipse 插件添加到播放中(在 plugins.sbt
文件中):
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")
然后添加到build.sbt
下设置:
// Eclipse settings
// Compile the project before generating Eclipse files,
// so that generated .scala or .class files for views and routes are present
EclipseKeys.preTasks := Seq(compile in Compile)
// Java project. Don't expect Scala IDE
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java
// Use .class files instead of generated .scala files for views and routes
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)
// End of eclipse settings
然后运行activator eclipse
过滤器库也发生了这种情况,特别是 "com.typesafe.play" % "filters-helpers_2.11" % "2.4.2"
依赖项。
它应该可以从 Maven2 repo and the Typesafe Releases repo. Both of which are implicitly included in SBT's build.sbt file since they are predefined repos in SBT.
我的公司用 SSL 证书做各种奇怪的事情(他们基本上是重新签名)。对于我的情况,我认为真正的问题是激活器不信任证书,因为公司 proxy/firewall 搞砸了它。我能够通过告诉激活器不要使用 JVM 参数检查证书是否受信任来修复它。
要进入禁用证书检查的激活器 shell,只需键入:
activator -Dcom.sun.net.ssl.checkRevocation=false
然后您可以像往常一样 compile
或 run
并且 activator/SBT 应该下载依赖项,即使它们不是通过受信任的连接。
注意:我很少这样做是为了将麻烦的依赖项下载到我的本地缓存中。 运行 没有证书检查的激活器有点不安全,因为下载不受信任的依赖项可能会让您面临 trojan/MITM 攻击。
似乎是导入错误。我在 Eclipse 中为导入做了一个自动安排,它从我的 Java class:
中删除了以下导入语句进口play.filters.cors.CORSFilter
由于不存在导入,即使 Activator 在构建时下载依赖项,它也无法找到 CORSFilter class,因为 Eclipse 在安排导入时删除了它。我再次添加了导入,虽然它在 Eclipse 中给出了 play.filters.cors 包未找到的错误,但正如预期的那样,它在构建时工作正常。
这看起来像是一个愚蠢的错误,但很难找到,所以如果以后有人遇到同样的问题,请在这里分享。