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

Scala 2.13版本下Play框架Anorm依赖未解决的解决方法

Fixing Unresolved Anorm Dependency in Scala 2.13

Let's break down why you're hitting that sbt.librarymanagement.ResolveException and how to fix it:

Why the Error Happens

The Anorm version you're using (2.3.9) is extremely outdated—it's tied to Play Framework 2.3.x, which only supports Scala 2.10 and 2.11. When you use %% in your sbt dependency, it automatically appends your project's Scala version (2.13) to the artifact name, so sbt tries to find anorm_2.13:2.3.9. Since this artifact was never published (maintainers never built Anorm 2.3.9 for Scala 2.13), sbt can't resolve it.

Solutions

1. Upgrade Anorm to a Scala 2.13-Compatible Version

Anorm was later split off from the Play Framework into its own standalone library with a new group ID. To use a version that supports Scala 2.13:

  • Replace your existing dependency with a modern, compatible release. For example:

    libraryDependencies += "org.playframework.anorm" %% "anorm" % "2.6.10"
    

    (Any release from 2.6.0 onwards supports Scala 2.13; you can use newer versions if available.)

  • Important: Since this is a standalone Anorm, you'll need to update your code's import statements. Replace old imports like import play.api.db.anorm._ with import anorm._. Some API details may have changed from the Play-bound version, so you might need to adjust your code slightly.

2. Downgrade Scala to a Version Supported by Anorm 2.3.9

If you absolutely must stick with Anorm 2.3.9 (e.g., your project is locked to Play 2.3.x), you'll need to downgrade your Scala version to either 2.10 or 2.11. Add this to your build.sbt:

scalaVersion := "2.11.12"

This is the most recent stable release of Scala 2.11, fully compatible with Anorm 2.3.9.

Final Notes

Unless you have a hard requirement for the old Play 2.3.x ecosystem, upgrading to the standalone Anorm is the better long-term solution—it gives you bug fixes, new features, and compatibility with modern Scala versions.

内容的提问来源于stack exchange,提问作者koko ka

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 06:30:00