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

Scala新手Windows配置sbt 1.x连接Nexus仓库失败求助

Fixing sbt Nexus Repository Setup on Windows

Hey there! I’ve been in your exact situation before—getting sbt to play nice with a corporate Nexus repo instead of the default Maven Central can feel a bit tricky at first, but let’s walk through this step by step to get you up and running.

1. Set Up Global Repository Configuration (Applies to All Projects)

On Windows, sbt checks for a global repo config file at C:\Users\<YourUsername>\.sbt\repositories. If this file doesn’t exist, create it with a text editor like Notepad or VS Code.

Paste in the following content, replacing the placeholder URLs with your company’s actual Nexus repository addresses:

[repositories]
local
my-nexus-releases: https://your-company-nexus-url/repository/maven-releases/
my-nexus-snapshots: https://your-company-nexus-url/repository/maven-snapshots/
# Optional: If your Nexus proxies Maven Central, replace the default central with this line
# central: https://your-company-nexus-url/repository/maven-central/
  • local keeps sbt’s cached local dependencies (always leave this in place)
  • my-nexus-releases points to your team’s stable release repository
  • my-nexus-snapshots is for snapshot builds (remove this if your team doesn’t use snapshots)

2. Add Nexus Authentication (If Required)

If your company’s Nexus requires a username and password, set up credentials like this:

  1. Create a file named .credentials in C:\Users\<YourUsername>\.sbt\
  2. Fill it with this template, replacing the placeholders:
realm=Sonatype Nexus Repository Manager
host=your-company-nexus-url
user=your-nexus-username
password=your-nexus-password
  1. To make sbt load these credentials globally, create or edit C:\Users\<YourUsername>\.sbt\1.0\global.sbt and add:
credentials += Credentials(Path.userHome / ".sbt" / ".credentials")

3. Project-Specific Configuration (Optional)

If you only want one project to use Nexus (instead of all your projects), skip the global setup and add this to your project’s build.sbt file:

// Add Nexus resolvers
resolvers ++= Seq(
  "My Nexus Releases" at "https://your-company-nexus-url/repository/maven-releases/",
  "My Nexus Snapshots" at "https://your-company-nexus-url/repository/maven-snapshots/"
)

// Load credentials from the .credentials file we created earlier
credentials += Credentials(Path.userHome / ".sbt" / ".credentials")

4. Test the Setup

Open a command prompt in your project directory and run:

sbt update

Check the output—you should see sbt pulling dependencies from your Nexus repo instead of the default Maven Central. If you hit errors, double-check your URLs, credentials, and make sure your Windows firewall isn’t blocking access to the Nexus server.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 07:07:05