且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

播放框架:包 javax.inject 不存在

更新时间:2022-05-21 02:56:05

这看起来像是在激活器中重新加载项目定义失败.

This looks like a failure to reload the project definition within activator.

如果我用以下内容更新我的 build.sbt,项目仍然会正确编译,因为依赖项没有问题,但因为它不知道更改.

If I update my build.sbt with the following, the project will still compile correctly not because there are no problems with the dependency but because it doesn't know about the changes.

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  javaWs,
  "foo" % "bar" % "1.0"
)

编译消息:

[exampleApp] $ compile
[success] Total time: 0 s, completed 29-apr-2015 9:13:30

如果我现在重新加载我的项目配置,我们就会开始看到问题.

If I now reload my project configuration, we'll start to see problems.

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: foo#bar;1.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: foo#bar;1.0: not found

这正是您添加需要特殊解析器的依赖项时所看到的,例如快照等.

This is exactly what you would see if you added a dependency that requires a special resolver, e.g. snapshots, etc.

让我们从 build.sbt 和 reload 中删除该行,以便我们可以正确编译,然后为项目中不存在的包添加导入.

Let's remove that line from build.sbt and reload so we can compile correctly, and then add an import for a package that doesn't exist within the project.

build.sbt(然后重新加载)

build.sbt (followed by a reload)

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  javaWs
)

Application.java

Application.java

import play.*;
import play.mvc.*;

import views.html.*;
import foo.bar.*;

public class Application extends Controller {

    public static Result index() {
        return ok(index.render("Your new application is ready."));
    }
}

编译这个结果

[error] D:	mpexampleAppappcontrollersApplication.java:7: error: package foo.bar does not exist
[error] import foo.bar.*;
[error] ^
[error] 1 error
[error] (compile:compile) javac returned nonzero exit code

这两个错误有非常不同的特征,结合上面提到的 dependencies 应该可以帮助你找到正确的地方.

The two errors have very distinct signatures, and this combined with dependencies as mentioned above should help guide you to the right place.