tapestry入門2

8102 ワード

tapestry入門2(翻訳)原文:http://tapestry.apache.org/creating-the-skeleton-application.htmlquickstartプロトタイプを使用する前に、空のアプリケーションを作成する必要があります.tapestryはmavenを使用してこのプロトタイプを作成します(より一般的な言い方は「プロジェクトテンプレート」です).mavenを使用して空のコマンドラインプログラムを作成し、プロジェクトをeclipseにインポートして残りの作業を完了します.このチュートリアルでは、eclipseと空のワークスペースを/Users/Howard/Documents/workspace 1に新しい方法でインストールします.オペレーティングシステムが異なる場合は、いくつかのパスを調整する必要があります.ワークスペースディレクトリでは、mavenを使用してtapestryプロジェクトフレームワークを作成します.続行する前に、mavenのgroup id(会社id)、artifact id(プロジェクトid)、version(バージョン)、base package name(ベースパスパッケージ名)mavenがgroup idとartifact idを使用して一意のアプリケーションIDを決定する4つのことを決定する必要があります.tapestryは、パッケージとコンポーネントがどこで見つかったかをベースパスパッケージ名で知る必要があります.この例ではgroup idはcomです.example,artifact idはtutorial 1,versionは1.0-SNAPSHOT,ベースパスパケット名はcom.example.tutorialの最終的な命令は次のとおりです.
 
(注:私はまずmaven 3をインストールして、mavenの公式サイトでzipファイルをダウンロードして、それから本機のあるディレクトリに解凍して、それからM 2、M 2_HOME、PATH、JAVA_HOMEなどの変数を設定して、pathはmavenのbinとjava_homeのディレクトリbinディレクトリをすべて含みます)
 
 
mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org
 
次に、プロトタイプを選択するよう求められます.latest Tapestryを選択してください.X Quickstart Project、プロンプトにgroup id、artifact id、version、packageを入力します.
$ mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom <<<
[INFO] 
[INFO] --- maven-archetype-plugin:2.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: http://tapestry.apache.org -> org.apache.tapestry:quickstart (Tapestry 5 Quickstart Project)
2: http://tapestry.apache.org -> org.apache.tapestry:tapestry-archetype (Tapestry 4.1.6 Archetype)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 1
Choose version: 
1: 5.0.19
2: 5.1.0.5
3: 5.2.6
4: 5.3
5: 5.3.1
6: 5.3.2
7: 5.3.4
Choose a number: 7: 7
Define value for property 'groupId': : com.example
Define value for property 'artifactId': : tutorial1
Define value for property 'version':  1.0-SNAPSHOT: : 
Define value for property 'package':  com.example: : com.example.tutorial 
Confirm properties configuration:
groupId: com.example
artifactId: tutorial1
version: 1.0-SNAPSHOT
package: com.example.tutorial
 Y: : 
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: quickstart:5.3.4
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.example
[INFO] Parameter: artifactId, Value: tutorial1
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.example.tutorial
[INFO] Parameter: packageInPathFormat, Value: com/example/tutorial
[INFO] Parameter: package, Value: com.example.tutorial
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: com.example
[INFO] Parameter: artifactId, Value: tutorial1
[WARNING] Don't override file /Users/hlship/Documents/workspace/tutorial1/src/test/java
[WARNING] Don't override file /Users/hlship/Documents/workspace/tutorial1/src/main/webapp
[WARNING] Don't override file /Users/hlship/Documents/workspace/tutorial1/src/main/resources/com/example/tutorial
[WARNING] Don't override file /Users/hlship/Documents/workspace/tutorial1/src/test/resources
[WARNING] Don't override file /Users/hlship/Documents/workspace/tutorial1/src/test/conf
[WARNING] Don't override file /Users/hlship/Documents/workspace/tutorial1/src/site
[INFO] project created from Archetype in dir: /Users/hlship/Documents/workspace/tutorial1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.398s
[INFO] Finished at: Tue Nov 22 11:46:08 PST 2011
[INFO] Final Memory: 7M/81M
[INFO] ------------------------------------------------------------------------
~/Documents/workspace
$ 
 
maveを初めて使用すると、主にjarパッケージや他のファイルをダウンロードする出力が多く見られます.これらのダウンロードしたファイルはローカルでキャッシュされ、再びダウンロードされません.しかし、最初は少し辛抱強くしなければなりません.このコマンドを実行すると、新しいディレクトリが表示されます.tutorial 1がファイアウォールに偽入すると、mvnコマンドを実行する前に、settingsでエージェントを構成する必要があります.xml.次に例を示します.
<settings>
  <proxies>
    <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>myProxyServer.com</host>
      <port>8080</port>
      <username>joeuser</username>
      <password>myPassword</password>
      <nonProxyHosts></nonProxyHosts>
    </proxy>
  </proxies>
  <localRepository>C:/Documents and Settings/joeuser/.m2/repository</localRepository>
</settings>
 
もちろん、localRepository要素の値をパソコンに適用するように変更します.jettyを使用して新しいアプリケーションを実行するには、まずmavenを使用してjettyを実行してプロジェクトディレクトリに入るとcd tutorial 1になります.そしてこのコマンドを実行します
 
cd tutorial1
mvn jetty:run

 
もう一度、まず、jettyが起動する前にそうだったことを知っています.Jettyが初期化されると(数秒で)、次の内容が表示されます.
TranslatorSource: DEFINED
                               TypeCoercer: REAL
                                URLEncoder: DEFINED
                         UpdateListenerHub: DEFINED
                    ValidateBindingFactory: DEFINED
             ValidationConstraintGenerator: DEFINED
                ValidationDecoratorFactory: DEFINED
                            ValidatorMacro: DEFINED
                        ValueEncoderSource: DEFINED

86.77% unrealized services (164/189)

Application 'app' (version 1.0-SNAPSHOT-DEV) startup time: 137 ms to build IoC Registry, 705 ms overall.

 ______                  __             ____
/_  __/__ ____  ___ ___ / /_______ __  / __/
 / / / _ `/ _ \/ -_|_-</ __/ __/ // / /__ \ 
/_/  \_,_/ .__/\__/___/\__/_/  \_, / /____/
        /_/                   /___/  5.3.4 (development mode)


2011-11-22 11:46:45.636::INFO:  Started [email protected]:8080
[INFO] Started Jetty Server
 
 
ブラウザを開いて入力できますhttp://localhost:8080/tutorial1/に表示されます.tapestry入门2ページの間の日付と時間は、リアルタイムのアプリケーションであることを証明しています.これは完全な小さなアプリケーションで、あまりやっていませんが、共通のレイアウトのあるページを作成する方法を示し、簡単なナビゲーションとリンクを示しています.3つの異なるページが共通のレイアウトを共有していることがわかります.
次のチュートリアルを続行する前に、コンソールでControl-Cを押してjettyを閉じることができます.
 
下一篇:
http://xieye.iteye.com/blog/1663495
上一篇:
http://xieye.iteye.com/blog/1663773