- Lift Application Development Cookbook
- Gilberto T. Garcia Jr.
- 725字
- 2021-08-04 10:05:42
Creating a Lift application using SBT
SBT is a build tool for Scala and Java projects. The idea of using a build tool such as SBT is to make it easier to manage all of the project dependencies. Also, it helps to ensure that the application generated by the build process is always the same. This means that it doesn't matter whether the application is built on my computer or yours, the end result will be the same.
The easiest way to start with Lift and SBT is by downloading them from the official website. There, you can find a list of tar.gz
and .zip
files containing everything you need to start using Lift.
Getting ready
Scala, and in turn, the Lift development requires a JVM and because of this, you'll need to install Java 7 on your computer. However, you can skip this step if you already have it installed. If not then go to http://java.com and click on the Free Java Download button. Then, download and install the JDK appropriate for your OS.
How to do it...
Carry out the following steps:
- First of all, to install and run Lift on Windows, you will need to download the
Lift 2.5
ZIP file, which is the latest stable release, from http://liftweb.net/download. - After the download is complete, open Windows Explorer and extract the contents from the file.
- Then, go to
scala_210/ift_basic
, double click on thesbt.bat
file to run SBT, and wait until SBT finishes downloading the required libraries. This process can take a while depending on the speed of your internet connection.When the download part is completed, you will get the SBT prompt that can be recognized by the
>
character. - After getting into the SBT prompt, type the following command to start the basic Lift application:
> container:start
- At this point, we have a running Lift application. So, open up your favorite browser and go to
http://localhost:8080
. Then you should see a welcome window similar to the following screenshot: - To exit SBT, you just need to type the following command in the SBT prompt:
> exit
How it works...
The ZIP file contains some examples of Lift applications such as a blank application that you can use to start your application from scratch. It also contains a basic Lift application that contains Blueprint CSS and ready-to-use Mapper models, which you can use as the start point when building your own application.
The lift_basic
folder contains a working Lift application. This means that you have SBT and a configured, ready-to-use project in it.
When we ran SBT, it started to download all the required libraries that the application needs (these dependencies are defined in the build.sbt
file). Once this step is done, we can start the application.
After downloading the required libraries, we ran the container:start
command provided by the sbt-web-plugin that deploys the Lift application into an embedded Jetty server.
You can see that inside the lift_basic
application, there is a folder called project
which contains a file called project.sbt
. In that file, you will see that it defines three plugins for SBT. The first defined plugin is the XSBT plugin. After the XSBT plugin, there is the sbt-idea plugin and the sbteclipse plugin. The former is to enable SBT to be integrated with IntelliJ IDEA, and the latter enables SBT to be integrated with Scala IDE. Another thing to notice in the plugins.sbt
file is that it matches the version of SBT to select the correct version of the sbt-web-plugin.
There's more...
To install and run Lift on Linux or Mac, perform the following steps:
- Download the
Lift 2.5 ZIP
or thetar.gz
file from http://liftweb.net/download. - Once you've got the file, open a shell tool and expand it.
- Then, go to
scala_210/lift_basic
, and start SBT by running the following command:./sbt
- You can then continue from step 4 of the How to do it… section.
See also
- You can read the
README.md
file and explore each sample application folder to learn more about what is bundled within Lift's ZIP file - You can find more about the sbt-web-plugin at the following URL: https://github.com/JamesEarlDouglas/xsbt-web-plugin
- Please navigate to https://github.com/mpeltonen/sbt-idea to get to know more about the SBT plugin for IntelliJ IDEA
- Please navigate to https://github.com/typesafehub/sbteclipse to learn more about the SBT plugin for ScalaIDE/Eclipse
- To find more about SBT, please go to http://www.scala-sbt.org/
- iOS Game Programming Cookbook
- 自己動手寫搜索引擎
- 國際大學生程序設計競賽中山大學內部選拔真題解(二)
- 編程的修煉
- CockroachDB權威指南
- Object-Oriented JavaScript(Second Edition)
- Flash CS6中文版應用教程(第三版)
- 21天學通C++(第6版)
- 用Flutter極速構建原生應用
- Java語言程序設計教程
- Internet of Things with ESP8266
- SAP Web Dynpro for ABAP開發技術詳解:基礎應用
- Android編程權威指南(第4版)
- Dart:Scalable Application Development
- 你必須知道的.NET(第2版)