使用Play Java Starter Example 2.5.x时找不到PlayEbean,求助
Hey Denis, let's fix that "Can not find PlayEbean Play 2.5.x" error you're hitting. This is almost always a mismatch in your sbt plugin or dependency configurations—Play 2.5.x has specific requirements for Ebean integration that differ from newer versions. Here's how to get it sorted:
1. Correct your plugins.sbt configuration
PlayEbean is distributed as an sbt plugin for Play 2.5.x, so you need to add the compatible plugin version to your project/plugins.sbt file. For Play 2.5.x, use the 3.x series of sbt-play-ebean (since 4.x+ is built for Play 2.6 and above). Here's the exact line you should add:
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "3.0.2")
Double-check that you don't have a newer plugin version here—using an incompatible version is the most common cause of this "not found" error.
2. Update your build.sbt to enable the plugin and add dependencies
Next, make sure your project activates the PlayEbean plugin and includes the required Ebean runtime dependencies. Your build.sbt should look like this:
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean) libraryDependencies ++= Seq( javaJdbc, cache, javaWs, // Add Ebean API dependency (matches the plugin's compatible version) "io.ebean" % "ebean" % "11.36.1" )
Key notes here:
- The
enablePlugins(PlayEbean)line tells sbt to activate the Ebean plugin for your project. - The Ebean version must align with your
sbt-play-ebeanplugin version (3.0.2 works seamlessly with Ebean 11.x).
3. Verify application.conf Ebean settings
Finally, ensure your conf/application.conf has the correct configuration to scan for Ebean models. Add this line to specify which packages contain your entity classes:
ebean.default = ["models.*"]
This tells Play where to find your database models so Ebean can map them properly.
Extra troubleshooting steps
- If the error persists, run
sbt clean updateto clear cached dependencies and pull the correct versions fresh. - Double-check for typos in your plugin or dependency coordinates—even a small typo can trigger "not found" errors.
Once you've made these changes, restart your Play application, and the error should be resolved.
内容的提问来源于stack exchange,提问作者Denis P

