IntelliJ中Scala sbt同步失败:添加Scalacheck后依赖缺失
Let's work through this issue step by step—your build.sbt configuration looks correct, so the problem is likely with how IntelliJ is handling the sbt import or caching. Here are the most effective fixes:
Use the sbt panel refresh instead of File → Synchronize
TheFile → Synchronizeoption only syncs file system changes, not sbt dependencies. Open the sbt tool window (go toView → Tool Windows → sbtif it's hidden), then click the circular refresh icon in the top toolbar. This triggers a proper sbt import that should pull in your test dependencies like Scalacheck.Invalidate IntelliJ caches and restart
Corrupted IDE cache is a common culprit here. Go toFile → Invalidate Caches..., select the "Invalidate and Restart" option, and let IntelliJ reboot. This clears stale cache data that might be blocking dependency detection.Pull dependencies manually via sbt first
Open a terminal in your project root directory and run:sbt test:compileThis forces sbt to download all test-scoped dependencies (including Scalacheck) directly. Once the command completes successfully, go back to IntelliJ and refresh the sbt project again.
Verify your sbt settings in IntelliJ
Double-check that IntelliJ is using the correct sbt and Scala versions:- Go to
File → Settings → Build, Execution, Deployment → Build Tools → sbt - Ensure the "Scala SDK" matches the
scalaVersionin your build.sbt (2.12.6 in your case) - Try toggling the "Use sbt shell for build and import" option (sometimes switching it off and back on resolves import bugs)
- Go to
Check for network issues
If thesbt test:compilecommand fails, you might have trouble accessing Maven Central. Verify your network connection, disable any proxies that might be blocking access, or check if your organization uses a private repository that requires additional configuration in build.sbt.
内容的提问来源于stack exchange,提问作者holothuroid

