问题描述
我正尝试从play 2.5.x升级到2.6.3. (因为2.5.x不支持WS中的多部分内容.import play.api.libs.ws.DefaultBodyWritables._引发异常.官方文档中的代码示例不起作用.编译器需要Body Writables,而Body Writables则不直到2.6.x为止
I am trying to upgrade from play 2.5.x to 2.6.3. (Because 2.5.x doesn't support multipart post in WS. import play.api.libs.ws.DefaultBodyWritables._ throws Exceptions. The code example in the official document doesn't work. The compiler needs the Body Writables which is not provided until 2.6.x)
因此,我将plugin.sbt版本更改为2.6.3,并将sbt升级为0.13.15.并编辑build.sbt文件以添加guice和json.该项目编译良好.但是,当我开始运行sbt并访问 http://localhost:9000 时,它抛出了一系列与我在本地lib/目录中有一个jar文件.相同的代码在2.5.x下也可以正常工作.
So I changed the plugin.sbt version to 2.6.3 and upgraded sbt to 0.13.15. And edit the build.sbt file to add guice and json. The project compiles fine. But when I started with sbt run, and visit http://localhost:9000, it throws a bunch of Exception related to a jar file I have in the local lib/ directory. The same code worked just fine with 2.5.x.
例外:
是否知道与本地jar相关的版本与2.6.x不兼容?还是我需要更改一些代码以进行依赖注入,而不是在Module.scala文件中指定?谢谢.
Any idea if this is related to the local jar is not compatible with 2.6.x? or I need to change some code to do dependency injection other than specify in the Module.scala file? Thanks.
推荐答案
为什么我会在Java中收到NoClassDefFoundError?
错误注入构造函数java.lang.NoClassDefFoundError:com/twitter/finagle/http/Method $ Get $
A => B => X(版本1)
A => B => X (version 1)
A => X(版本2)
A => X (version 2)
然后,当它运行时,A向B发出呼叫,B尝试发出呼叫 进入X,但是因为该项目现在使用的是更新版本,而不是 较旧的版本,找不到所需的类.
Then when it runs, A makes a call into B, which tries to make a call into X, but because the project now uses the newer version instead of the older version, it can't find the class it needs.
我鼓励您使用sbt-dependency-graph查看哪个 您依赖的[库名称]的版本,并确保 您使用的每个库都使用相同版本的[库名].
I would encourage you to use sbt-dependency-graph to see which versions of [library name] you're depending on transitively, and ensure that every library you use uses the same version of [library name].
看起来像本地jar的问题.
Looks like an issue with the local jar.
这篇关于将Play框架从2.5.x升级到2.6.x时如何解决依赖注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!