C01.

設置 SCALA_HOME 環境變量

SCALA_HOME=/KuoJavaLibrary/scala-2.8.0
export SCALA_HOME
PATH=$PATH:$SCALA_HOME/bin
export PATH


Apache Maven
Lift 依靠 Apache Maven 設置專案、測試Code等。需要 Apache Maven

Maven Brower, http://www.mvnbrowser.com/artifacts-browse.html?

Command - mvn
mvn archetype:generate -U -DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift-archetype-blank -DarchetypeVersion=1.0 -DremoteRepositories=http://scala-tools.org/repo-releases -DgroupId=demo.helloworld -DartifactId=helloworld -Dversion=1.0-SNAPSHOT


mvn archetype:generate -U -DarchetypeGroupId=net.liftweb -DarchetypeArtifactId=lift-archetype-blank -DarchetypeVersion=1.1-M7 -DremoteRepositories=http://scala-tools.org/repo-releases -DgroupId=demo.helloworld -DartifactId=helloworld -Dversion=1.0-SNAPSHOT


mvn archetype:generate -U \
-DarchetypeGroupId=net.liftweb \
-DarchetypeArtifactId=lift-archetype-blank \
-DarchetypeVersion=1.1-M7 \
-DremoteRepositories=http://scala-tools.org/repo-releases \
-DgroupId=demo.helloworld \
-DartifactId=helloworld \
-Dversion=1.0-SNAPSHOT


[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [net.liftweb:lift-archetype-blank:RELEASE -> http://scala-tools.org/repo-releases] found in catalog internal
Confirm properties configuration:
groupId: demo.helloworld
artifactId: helloworld
version: 1.0-SNAPSHOT
package: demo.helloworld
 Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating OldArchetype: lift-archetype-blank:1.1-M7
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: demo.helloworld
[INFO] Parameter: packageName, Value: demo.helloworld
[INFO] Parameter: package, Value: demo.helloworld
[INFO] Parameter: artifactId, Value: helloworld
[INFO] Parameter: basedir, Value: /Users/ChaoYi/Documents/workspace/LiftDemo
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] ********************* End of debug info from resources from generated POM ***********************
[INFO] OldArchetype created in dir: /Users/ChaoYi/Documents/workspace/LiftDemo/helloworld
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 26 seconds
[INFO] Finished at: Wed Nov 25 04:19:35 CST 2009
[INFO] Final Memory: 12M/79M
[INFO] ------------------------------------------------------------------------
Win95:LiftDemo ChaoYi$


LiftDemo ChaoYi$ du -ha helloworld/
8.0K    helloworld//pom.xml
  0B    helloworld//src/main/resources
4.0K    helloworld//src/main/scala/bootstrap/liftweb/Boot.scala
4.0K    helloworld//src/main/scala/bootstrap/liftweb
4.0K    helloworld//src/main/scala/bootstrap
  0B    helloworld//src/main/scala/demo/helloworld/comet/.keep
  0B    helloworld//src/main/scala/demo/helloworld/comet
  0B    helloworld//src/main/scala/demo/helloworld/model/.keep
  0B    helloworld//src/main/scala/demo/helloworld/model
  0B    helloworld//src/main/scala/demo/helloworld/snippet/.keep
4.0K    helloworld//src/main/scala/demo/helloworld/snippet/HelloWorld.scala
4.0K    helloworld//src/main/scala/demo/helloworld/snippet
  0B    helloworld//src/main/scala/demo/helloworld/view/.keep
  0B    helloworld//src/main/scala/demo/helloworld/view
4.0K    helloworld//src/main/scala/demo/helloworld
4.0K    helloworld//src/main/scala/demo
8.0K    helloworld//src/main/scala
4.0K    helloworld//src/main/webapp/index.html
4.0K    helloworld//src/main/webapp/templates-hidden/default.html
4.0K    helloworld//src/main/webapp/templates-hidden
4.0K    helloworld//src/main/webapp/WEB-INF/web.xml
4.0K    helloworld//src/main/webapp/WEB-INF
 12K    helloworld//src/main/webapp
 20K    helloworld//src/main
  0B    helloworld//src/test/resources
4.0K    helloworld//src/test/scala/demo/helloworld/AppTest.scala
4.0K    helloworld//src/test/scala/demo/helloworld
4.0K    helloworld//src/test/scala/demo
4.0K    helloworld//src/test/scala/LiftConsole.scala
4.0K    helloworld//src/test/scala/RunWebApp.scala
 12K    helloworld//src/test/scala
 12K    helloworld//src/test
 32K    helloworld//src
 40K    helloworld/



http://scala-tools.org/mvnsites/liftweb/


http://demo.liftweb.net/


Lift 是一個完整的 Web 應用程序庫。它提供完整的模型-視圖-控制器(Model-View-Controller,MVC)實現,儘管它使用的方法與大多數普通的 MVC 框架有些不同。它大量使用 Maven 來構建項目結構,從而滿足依賴性。這就是為何不需要下載或安裝 Scala 就可以使用 Lift 的原因 — 這一切都已經為您準備好了!這還解釋了為何不需要資料庫或 Web 服務器就可以使用 Lift;它使用 Maven 包含一個資料庫(Apache Derby)和一個 Web 服務器(Jetty)。事實上,Jetty 非常適合 Comet 風格的應用程序;Lift 利用了這些特點,因此不需要下載任何東西。




結合使用 Apache Geronimo 和 Lift, http://www.ibm.com/developerworks/cn/opensource/os-ag-lift/

[tips] 淺嘗 lift



mvn jetty:run
http://127.0.0.1:8080/
    
src/main/webapp/index.html
<lift:surround with="default" at="content">
                <h2>Welcome to your project!</h2>
                <p><lift:helloWorld.howdy /></p>
</lift:surround>

Lift’s template system
src/main/webapp/templates-hidden/default.html
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:lift="http://liftweb.net/">
        <head>
                <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
                <meta name="description" content="" />
                <meta name="keywords" content="" />

                <title>demo.helloworld:helloworld:1.0-SNAPSHOT</title>
                <script id="jquery" src="/classpath/jquery.js" type="text/javascript"></script>
        </head>
        <body>
                <lift:bind name="content" />
                <lift:Menu.builder />
                <lift:msgs/>
        </body>
</html>



Comments