版本
- scala:2.12.8
- sbt: 1.2.8
- play : 2.7.2
配置
- sbt 配置 ,用户/.sbt/repo.properties
[repositories]
local
maven-local: file:D:/mvnrepo
aliyun: http://maven.aliyun.com/nexus/content/groups/public/
ibiblio: http://maven.ibiblio.org/maven2/
central: http://central.maven.org/maven2/
wso2: http://maven.wso2.org/nexus/content/repositories/public/
nuxeo: https://maven-eu.nuxeo.org/nexus/content/repositories/public-releases/
aliyun-ivy: http://maven.aliyun.com/nexus/content/groups/public/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
sbt-plugin-ivy: http://dl.bintray.com/sbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
dl-ivy: http://dl.bintray.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
repo1: http://repo1.maven.org/maven2/, [organization]/[module]/[artifact]/[module]-[artifact].[ext]
sonatype-oss-releases
maven-central
sonatype-oss-snapshots
如果一直卡着,可以试试以下这个:
[repositories]
local
maven-local: file:D:/mvnrepo
Nexus osc : https://code.lds.org/nexus/content/groups/main-repo
Nexus osc thirdparty : https://code.lds.org/nexus/content/groups/plugin-repo/
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
typesafe2: http://repo.typesafe.com/typesafe/releases/
sbt-plugin: http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/
sonatype: http://oss.sonatype.org/content/repositories/snapshots
uk_maven: http://uk.maven.org/maven2/
ibibli: http://mirrors.ibiblio.org/maven2/
repo2: http://repo2.maven.org/maven2/
执行完后:
[SUCCESSFUL ] org.scala-sbt.ivy#ivy;2.3.0-sbt-cb9cc189e9f3af519f9f102e6c5d446488ff6832!ivy.jar (18329ms)
:: retrieving :: org.scala-sbt#boot-app
confs: [default]
80 artifacts copied, 0 already retrieved (28561kB/9802ms)
Getting Scala 2.12.7 (for sbt)...
:: retrieving :: org.scala-sbt#boot-scala
confs: [default]
5 artifacts copied, 0 already retrieved (19715kB/638ms)
[warn] No sbt.version set in project/build.properties, base directory: D:\dev\sbt-1.2.8\bin
[info] Set current project to bin (in build file:/D:/dev/sbt-1.2.8/bin/)
[info] sbt server started at local:sbt-server-0c9cd95de9f3b0fd5266
sbt:bin> sbtVersion
[info] 1.2.8
- sbt/conf
- repo.properties 与上面的相同
- sbtconfig.txt
-Xmx512M
-XX:MaxPermSize=256m
-XX:ReservedCodeCacheSize=128m
-Dsbt.log.format=true
-Dsbt.boot.directory=D:/dev/sbt-1.2.8/.sbt/boot
-Dsbt.global.base=D:/dev/sbt-1.2.8/.sbt
-Dsbt.ivy.home=D:/dev/sbt-1.2.8/.ivy2
-Dsbt.repository.config=D:/dev/sbt-1.2.8/conf/repo.properties
-Dsbt.repository.secure=false
- sbtopts
# ------------------------------------------------ #
# The SBT Configuration file. #
# ------------------------------------------------ #
-sbt-create
-sbt-dir D:/dev/sbt-1.2.8/.sbt
-sbt-boot D:/dev/sbt-1.2.8/.sbt/boot
-ivy D:/dev/sbt-1.2.8/.ivy2
-scala-home D:/dev/scala-2.12.8
-scala-version 2.12.8
- 打开命令窗口,执行 sbt-1.2.8\bin\sbt.bat
idea 创建 play2项目后,修改配置
- build.sbt
name := "play01"
version := "1.0"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.12.8"
crossScalaVersions := Seq("2.12.8", "2.11.12")
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.2" % Test
- project/build.properties
sbt.version=1.2.8
示例
https://github.com/playframework/play-samples
数据库连接
https://playframework.github.io/anorm/
配置
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.12.8"
crossScalaVersions := Seq("2.12.8", "2.11.12")
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.2" % Test
libraryDependencies ++= Seq(
evolutions,
jdbc,
javaJdbc,
javaWs,
javaJpa,
"org.hibernate" % "hibernate-entitymanager" % "5.0.12.Final",
"org.playframework.anorm" %% "anorm" % "2.6.2",
"mysql" % "mysql-connector-java" % "5.1.47"
)