sbt的那些事

~/.sbt/repositories 远程镜像

若没有默认访问https://repo1.maven.org/maven2
也可修改:~/.sbt/repositories

[repositories]
local    ##表示本地路径~/.ivy2
my-nexus: https://127.0.0.1:8081/nexus/public/  ## 指向本地搭建的nexus 私服
aliyun: http://maven.aliyun.com/nexus/content/groups/public/ ## 指向阿里云镜像
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-oss-releases
maven-central  ## 默认maven ,maven-central 属于sbt 内置变量
sonatype-oss-snapshots

sbt 代理设置 https://www.scala-sbt.org/1.x/docs/Proxy-Repositories.html

build.sbt 依赖格式

libraryDependencies += "com.google.code.gson" % "gson" % "2.9.1"

死活不对报错,发现依赖格式错误

[error] (update) sbt.librarymanagement.ResolveException: Error downloading com.google.code.gson:gson_2.11:2.9.1
[error]   Not found
[error]   Not found
[error]   not found: https://repo1.maven.org/maven2/com/google/code/gson/gson_2.11/2.9.1/gson_2.11-2.9.1.pom
[error]   not found: https://maven.aliyun.com/repository/public/com/google/code/gson/gson_2.11/2.9.1/gson_2.11-2.9.1.pom

buildsbt %% 和% 的区别

libraryDependencies += "com.google.code.gson" %% "gson" % "2.9.1"

%%表示带上scala的version com/google/code/gson/gson_2.11/2.9.1

libraryDependencies += "com.google.code.gson" % "gson" % "2.9.1"

% 表示不带scala version com/google/code/gson/gson/2.9.1

参见 sbt 文档
在这里插入图片描述
完整的build.sbt

ThisBuild / version := "1.0"
ThisBuild / scalaVersion := "3.11.12"
ThisBuild / organization := "mi.com"

resolvers += DefaultMavenRepository

val spinalVersion = "1.7.2"
val spinalCore = "com.github.spinalhdl" %% "spinalhdl-core" % spinalVersion
val spinalLib = "com.github.spinalhdl" %% "spinalhdl-lib" % spinalVersion
val spinalIdslPlugin = compilerPlugin("com.github.spinalhdl" %% "spinalhdl-idsl-plugin" % spinalVersion)

lazy val mylib = (project in file("."))
  .settings(
    name := "misoc",
    libraryDependencies ++= Seq(spinalCore, spinalLib, spinalIdslPlugin,
      "org.apache.poi" % "poi" % "3.17",
      "org.apache.poi" % "poi-ooxml" % "3.17"
    )
  )

libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "3.0.0"
libraryDependencies += "com.google.code.gson" % "gson" % "2.9.1"
libraryDependencies += "com.alibaba" % "fastjson" % "1.2.76"

fork := true
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值