初学Play框架运行示例项目时遭遇java.lang.NoClassDefFoundError错误
Fixing
java.lang.NoClassDefFoundError: com/trueaccord/scalapb/GeneratedEnum in Play 2.6.x Java Starter Project Hey there, I’ve dealt with this exact error when getting started with Play 2.6.x, so let’s get this sorted out for you! This error pops up because your project is missing the necessary scalapb library dependencies that Play relies on to load certain underlying components.
Step 1: Add the scalapb runtime dependency
- Open your project’s root
build.sbtfile in a text editor. - Find the
libraryDependenciessection, and add this line to it:
Note: Version 0.6.6 is fully compatible with Play 2.6.x—skip newer versions here, as they might introduce compatibility conflicts.libraryDependencies += "com.trueaccord.scalapb" %% "scalapb-runtime" % "0.6.6" % "protobuf"
Step 2: Verify (and add if missing) the protoc plugin
If your project doesn’t have the sbt-protoc plugin configured, you’ll need to add it too:
- Open
project/plugins.sbt - Add these lines if they’re not already present:
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.22") libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.6.6"
Step 3: Clean and restart the project
In your terminal, run these commands to clear cached artifacts and start the project fresh:
sbt clean run
That should resolve the NoClassDefFoundError and let your Play starter project run smoothly.
内容的提问来源于stack exchange,提问作者Julia Chen
相关产品推荐
相关产品推荐

