今天有位写框架的大哥叫我学一学scalatra框架,找了半天没几个教程是可以用的。
今天晚上整理一下,下面有完整的连接哟。要使用scalatra进行web开发首先必须使用google的sbt。
我找文档找了好久啊,终于找到这篇文档了.特来跟大家分享一下!
This page describes how to set up your project for use with sbt.
The basic steps are:
- Create a script to launch sbt.
- Create your project with sbt.
- Put libraries in lib and sources in src.
- Read RunningSbt for basic usage instructions.
- Read BuildConfiguration for further configuration.
The easiest way to launch sbt is to create a one-line script. Download sbt-launch.jar if you have not already.
Note: do not put sbt-launch.jar in your $SCALA_HOME/lib directory, your project's lib directory, or anywhere it will be put on a classpath.
Note: The encoding used by your terminal may differ from Java's default encoding for your platform. In this case, you will need to add the option -Dfile.encoding=<encoding> in the following scripts to set the encoding.
Put the jar in your ~/bin directory, put the line
java -Xmx512M -jar `dirname $0`/sbt-launch.jar "$@"
in a file called sbt in your ~/bin directory and do
$ chmod u+x ~/bin/sbt
This allows you to launch sbt in any directory by typing sbt at the command prompt.
sbt will pick up any HTTP proxy settings from the http.proxy environment variable. If you are behind a proxy requiring authentication, you must in addition pass flags to set the http.proxyUser and http.proxyPassword properties:
java -Dhttp.proxyUser=username -Dhttp.proxyPassword=mypassword -Xmx512M -jar `dirname $0`/sbt-launch.jar "$@"
Create a batch file sbt.bat:
set SCRIPT_DIR=%~dp0
java -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %*
and put the jar in the same directory as the batch file. Put sbt.bat on your path so that you can launch sbt in any directory by typing sbt at the command prompt.
If you are behind a proxy on Windows, add flags to this second line for proxy host, port, and if applicable, username and password:
java -Dhttp.proxyHost=myproxy -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=mypassword -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %*
When you run sbt and it does not find a project in the current directory, it asks if you want to create a new project. If you say yes, sbt will prompt for some basic information:
- Project name: This name will be used in scaladocs and as part of the default name for generated packages.
- Project organization: This is used for dependency management and is optional.
- Project version: This is used in scaladocs, as part of the default name for generated packages, and for dependency management.
- Scala version: This is version(s) of scala to build the project with. Multiple versions may be separated by spaces (see CrossBuild). Allowed values are (in theory) any version of Scala 2.7.2 or later available in the Scala Tools repository.
- Sbt version: This is the version of sbt to build the project with. Currently, this should be 0.7.0, 0.7.1, 0.7.2, 0.7.3, or 0.7.4.
See Loader for more information on setting the versions of Scala and sbt to use to build your project. With the above information, sbt creates the project properties file and directory structure. These are described in the following section.
In addition to 'yes' or 'no', you can type s (for scratch) when prompted to create a new project. This can be used to quickly get sbt compiling and running code without needing to do a full project setup. This option skips all of the prompts in a full setup and configures sbt to look in the current directory for sources and jars in addition to the usual places in a full project. Using sbt for a hello world might look like:
$ echo 'object Hi { def main(args: Array[String]) { println("Hi!") } }' > hw.scala
$ sbt
Project does not exist, create new project? (y/N/s) : s
...
> run
...
Hi!
Sbt uses the same directory structure as Maven for source files by default (all paths are relative to the project directory):
src/
main/
resources/
<files to include in main jar here>
scala/
<main Scala sources>
java/
<main Java sources>
test/
resources
<files to include in test jar here>
scala/
<test Scala sources>
java/
<test Java sources>
Other directories in src/ will be ignored. Additionally, all hidden directories will be ignored.
All dependencies (jars) go in the
lib/
directory or any subdirectory of lib. Again, hidden directories will be ignored. If you want to use ScalaCheck, specs, or ScalaTest for testing, those jars should go in here as well. Alternatively, you can configure sbt to automatically manage your dependencies (see LibraryManagement).
Build configuration is done in the project directory:
project/
build.properties
build/
boot/
The build.properties file contains the project name, version, and organization, the versions of Scala and sbt used to build the project, and any other user-defined properties (see Properties). You can directly edit this file to change these properties or you can use the set command at the interactive prompt (see Basic Usage). The build directory is where further configuration is done and is described in BuildConfiguration. The boot directory is where the versions of Scala and sbt used to build the project are downloaded to.
Generated files (classes, jars, analysis, and documentation) will be written to the
target/
directory. Automatically managed dependencies are downloaded to:
lib_managed/
sbt creates and uses several directories that you will normally want to exclude from version control:
target/
lib_managed/
project/boot/
project/build/target/
project/plugins/target/
project/plugins/lib_managed/
project/plugins/src_managed/
A .gitignore for an sbt project should contain these entries:
target/
lib_managed/
src_managed/
project/boot/
Read Basic Usage for basic sbt usage information.
- Create a launcher script.
- Setup your project information and directory structure by running sbt in your project directory.
- Put libraries in lib or configure automatic dependency management.
- Read RunningSbt for basic usage instructions.
- Start with BuildConfiguration for further project configuration
发表评论
-
Scala + Twitter = Scitter(scala代码学习第15天)
2011-04-08 09:11 865Twitter 迅速占领了 Interne ... -
面向 Java 开发人员的 Scala 指南: Scala 和 servlet(scala代码学习第十一天)
2011-04-02 07:40 732Scala 显然是一门有趣的语言,很适合体现语言理论和创新方面 ... -
构建计算器,第 3 部分将 Scala 解析器组合子和 case 类结合起来(scala代码学习第十天)
2011-04-01 09:25 950欢迎勇于探索的读者回到我们的系列文章中!本月继续探索 Scal ... -
scala代码学习构建计算器,第2 部分(代码学习第九天)
2011-03-31 10:53 808回忆一下我们的英雄所处的困境:在试图创建一个 DSL(这里只不 ... -
Scala构建计算器,第1 部分(代码学习第8天)
2011-03-30 11:59 1193特定于领域的语言 可能您无法(或没有时间)承受来自于您的项目 ... -
scala包和访问修饰符(代码学习第七天)
2011-03-29 15:51 1615系列的过程中我遗漏了 ... -
实现继承(代码学习第五天)
2011-03-26 10:13 963近十几年来,面向对象语言设计的要素一直是继承的核心。不支持继承 ... -
关于特征和行为(代码学习第四天)
2011-03-25 09:38 698著名科学家、研究学者 ... -
Scala 控制结构内部揭密(scala代码学习第三天)
2011-03-24 09:15 1304迄今为止,在此 系列 ... -
面向 Java 开发人员的 Scala 指南: 类操作(代码学习第2天)
2011-03-22 19:06 740第一天中只是些简单应用 ,您只是稍微了解了一些 Scala 语 ... -
programming in scala 2nd代码学习(第一天)
2011-03-22 18:42 932近来没事,拿出了原先学习scala的代码 书中代码噢、拿出自己 ... -
scalatra web框架快速搭建(官方使用文档)
2011-03-21 22:42 2513昨天写了个sbt构建scala项目的文章,就是为了今天的sca ... -
Scala functional style deferent from java OOP(特点)
2011-03-20 17:34 981该程序通过一段斐波那契数列的计算,比较一下Scala的函数式编 ... -
Java 开发人员的 Scala 指南: 面向对象的函数编程
2011-03-20 11:59 1035函数概念 开始之前, ...
相关推荐
sbt(Simple Build Tool)是Scala项目的默认构建工具,它允许用户以声明性的方式定义项目依赖和构建过程。在本教程中,我们将深入探讨如何使用VSCode(Visual Studio Code)创建一个名为"Scala-SBT-Helloworld"的...
sbt(Simple Build Tool)是Scala项目的默认构建工具,它基于Apache Ivy依赖管理系统,为Scala和Java项目提供了强大的构建功能。sbt 1.2.8是该工具的一个较旧但仍然广泛使用的版本,它支持构建配置、自动编译、测试...
Equip yourself with a high-productivity work environment using SBT, a build tool for Scala Overview Establish simple and complex projects quickly Employ Scala code to define the build Write build ...
此外,插件还支持SBT(Simple Build Tool)构建系统,使得管理Scala项目的依赖和构建过程更为便捷。 对于Spark开发者来说,Scala插件更是一个不可或缺的工具。Apache Spark是一个分布式计算框架,其API主要使用...
SBT(Simple Build Tool)是 Scala 的构建工具,用于管理项目依赖关系和编译代码。要在 Windows 10 系统上安装 SBT,需要从官方网站下载 SBT 的安装包,网址为 ...
这个压缩包文件包含了sbt(Simple Build Tool)版本1.3.8的所有必要组件,允许开发者高效地构建、测试和管理他们的Scala或Java项目。 sbt是Scala社区广泛采用的构建工具,它的主要特点包括: 1. **自动化构建**:...
SBT,全称为 Simple Build Tool,它以其灵活性和高效性在 Scala 开发者社区中广泛应用。在这个API文档中,开发者可以找到关于如何使用SBT进行项目构建、依赖管理、测试以及发布等关键信息。 版本0.13.12是2016年11...
4. Scala 工具:包括 sbt(Simple Build Tool),这是 Scala 项目的主要构建工具,用于管理依赖、编译、打包和测试。 在提供的压缩包文件名称列表中,只提到了 "eclipse"。这可能意味着该 SDK 集成了 Eclipse IDE ...
8. **社区包管理**:Scala 2.13继续支持SBT(Simple Build Tool)作为主要的构建工具,同时也更加友好地支持Maven和Gradle等其他构建系统。 在解压“scala-2.13.0-M5.tgz”后,你会得到一系列文件和目录,包括Scala...
6. **Sbt构建工具**:"scala"压缩包可能包含了Scala的构建工具SBT(Simple Build Tool),它是Scala项目的主要构建工具,可以管理依赖、编译、打包和测试。 7. **社区和文档**:Scala拥有活跃的开发者社区,提供了...
此外,该插件还支持Scala的构建工具SBT(Simple Build Tool),方便项目的构建和管理。 标签"scala idea"表明这个压缩包是为Scala开发者在IntelliJ IDEA中进行开发准备的。IntelliJ IDEA的用户界面友好,性能优秀,...
**SBT(Scala Build Tool)** 是一个基于Java和Scala的高效、强大的构建工具,尤其在Scala开发领域中被广泛使用。它的全名是Simple Build Tool,正如其名,SBT旨在简化项目构建过程,提供了一种简洁的方式来管理依赖...
`sbt-launch`是专门为Windows操作系统设计的Scala项目构建工具SBT(Simple Build Tool)的启动器。SBT是Scala社区广泛使用的自动化构建系统,它允许开发者高效地管理依赖、编译、打包、测试以及发布Scala和Java项目...
Sbt(Simple Build Tool)是Scala项目的主要构建工具,它以其高效、灵活和强大的特性深受开发者喜爱。在 Scala 开发环境中,Sbt 起到了核心作用,它负责编译、测试、打包以及发布 Scala 应用程序。"sbt资源包,全...
**Simple Build Tool (sbt)** 是一个强大的构建工具,主要用于Scala和Java项目。它采用声明式的方式来定义项目构建,使得开发者能够轻松管理依赖、编译、打包、测试以及发布项目。sbt以其高效和灵活的特性,深受...
SBT(Simple Build Tool)是Scala编程语言生态系统中的核心构建工具,它为Scala开发者提供了一种高效、灵活的方式来管理项目依赖、编译源代码、运行测试以及打包应用程序。SBT的强大之处在于它能够自动化构建过程,...
8. **工具链**:Scala的构建工具sbt(Simple Build Tool)的相关代码也在源码包内,它使得Scala项目的构建和管理变得简单。 9. **兼容性**:Scala-2.11.x系列着重于与Java 7和8的兼容性,因此在源码中可以看到针对...
SBT是Scala的构建工具(Build Tool),其全称是Simple Build Tool,主要用于Scala和Java项目的构建和管理。通过SBT,开发者能够更高效地组织和执行项目的构建过程,包括编译代码、运行测试、打包应用等。 在描述中...
在工具链方面,Scala 2.12.5与SBT(Simple Build Tool)紧密集成,这是Scala项目的主要构建工具。SBT提供了高效的依赖管理和构建流程,使得开发者能够快速构建、测试和打包Scala项目。 最后,值得注意的是,Scala ...