You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

初学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.sbt file in a text editor.
  • Find the libraryDependencies section, and add this line to it:
    libraryDependencies += "com.trueaccord.scalapb" %% "scalapb-runtime" % "0.6.6" % "protobuf"
    
    Note: Version 0.6.6 is fully compatible with Play 2.6.x—skip newer versions here, as they might introduce compatibility conflicts.

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:24:00