playframework学习小记

版本

  • scala:2.12.8
  • sbt: 1.2.8
  • play : 2.7.2

配置

  1. 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
  1. 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"
)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qingxinziran007

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值