#freeze
[[Spring-MVC/ステップ・バイ・ステップ]]

2008/03/14からのアクセス回数 &counter;

#contents

EclipseでWebアプリケーションを作成する場合、ソースを変更するたびに
-- warファイルの作成
-- tomcat/webappsへのコピー
-- tomcatの起動
-- ブラウザーの起動

の一連の作業をしなくてはなりません。ここでは、これらの作業をjettyプラグインを使って
簡単に実行する方法を紹介します。

** jettyプラグインの設定 [#td51108e]
jettyプラグインを使うためには、pomファイルのbuildのpluginsに以下のpluginタグを
追加します。

#pre{{
	<plugins>
	  <plugin>
	    <groupId>org.mortbay.jetty</groupId>
	    <artifactId>maven-jetty-plugin</artifactId>
	    <version>6.1.7</version>
	  </plugin>		
	</plugins>
}}

** jettyの起動 [#jdf082b0]
mavenを使ってjettyを起動するには以下のように入力します。

#pre{{
$ mvn jetty:run
}}
すると、リソースの配備、コンパイル、テストリソースの配備、テストのコンパイルを実行し、jettyを
起動します。
コンソールには以下のように出力されます。
#pre{{
take-2:~/tmp/mvc-convention take$ mvn jetty:run
Listening for transport dt_socket at address: 1044
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'jetty'.
[INFO] ------------------------------------------------------------------------
[INFO] Building mvc-convention Maven Webapp
[INFO]    task-segment: [jetty:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing jetty:run
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [jetty:run]
[INFO] Configuring Jetty for project: mvc-convention Maven Webapp
[INFO] Webapp source directory = /Users/take/tmp/mvc-convention/src/main/webapp
[INFO] web.xml file = /Users/take/tmp/mvc-convention/src/main/webapp/WEB-INF/web.xml
[INFO] Classes = /Users/take/tmp/mvc-convention/target/classes
2008-03-14 15:32:09.951::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
[INFO] Context path = /mvc-convention
[INFO] Tmp directory =  determined at runtime
[INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] Webapp directory = /Users/take/tmp/mvc-convention/src/main/webapp
[INFO] Starting jetty 6.1.7 ...
2008-03-14 15:32:09.188::INFO:  jetty-6.1.7
2008-03-14 15:32:10.755::INFO:  No Transaction manager found - if your webapp requires one, please configure one.
2008-03-14 15:32:11.980::INFO:  Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server
}}

** ブラウザーでの確認 [#d05601d2]
[[mavenプロジェクトの作成>Spring-MVC/ステップ・バイ・ステップ/mavenプロジェクトの作成]]
で作成したプロジェクトをブラウザーで確認します。

ブラウザーで以下のように入力すると
#pre{{
http://localhost:8080/mvc-convention/
}}

Hello World!画面が表示します。

#ref(hello.jpg);

** jettyの停止 [#q688e2c8]
jettyを停止するには、コンソールからCtrl-C(コントロールキーとCを同時に押す)を入力します。

** コメント [#vdcbf507]
この記事は、

#vote(おもしろかった,そうでもない,わかりずらい)
#vote(おもしろかった[0],そうでもない[0],わかりずらい[1])

皆様のご意見、ご希望をお待ちしております。

#comment_kcaptcha


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
SmartDoc