Gwt-deploy-application
GWT-アプリケーションのデプロイ
このチュートリアルでは、アプリケーション "war" ファイルを作成する方法と、それをApache Tomcat Webseverルートにデプロイする方法を説明します。
この簡単な例を理解していれば、同じ手順に従って複雑なGWTアプリケーションをデプロイすることもできます。
GWTプラグインとともにEclipse IDEを使用し、次の手順に従ってGWTアプリケーションを作成します。
Step
説明
1
_GWT-アプリケーションの作成_の章の説明に従って、_com.finddevguides_パッケージの下に_HelloWorld_という名前のプロジェクトを作成します。
2
以下で説明するように、HelloWorld.gwt.xml _、 HelloWorld.css 、 HelloWorldl_、および_HelloWorld.java_を変更します。 残りのファイルは変更しないでください。
3
アプリケーションをコンパイルして実行し、要件に従ってビジネスロジックが機能していることを確認します。
4
最後に、アプリケーションのwarフォルダーのコンテンツをwarファイルの形式で圧縮し、Apache Tomcat Webserverにデプロイします。
5
以下の最後の手順で説明するように、適切なURLを使用してWebアプリケーションを起動します。
以下は、変更されたモジュール記述子 src/com.finddevguides/HelloWorld.gwt.xml の内容です。
<?xml version = "1.0" encoding = "UTF-8"?>
<module rename-to = 'helloworld'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name = 'com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. -->
<inherits name = 'com.google.gwt.user.theme.clean.Clean'/>
<!-- Specify the app entry point class. -->
<entry-point class = 'com.finddevguides.client.HelloWorld'/>
<!-- Specify the paths for translatable code -->
<source path = 'client'/>
<source path = 'shared'/>
</module>
以下は、変更されたスタイルシートファイル war/HelloWorld.css の内容です。
body {
text-align: center;
font-family: verdana, sans-serif;
}
h1 {
font-size: 2em;
font-weight: bold;
color: #777777;
margin: 40px 0px 70px;
text-align: center;
}
以下は、変更されたHTMLホストファイル war/HelloWorldl の内容です。
<html>
<head>
<title>Hello World</title>
<link rel = "stylesheet" href = "HelloWorld.css"/>
<script language = "javascript" src = "helloworld/helloworld.nocache.js">
</script>
</head>
<body>
<h1>Hello World</h1>
<div id = "gwtContainer"></div>
</body>
</html>
前の例からHTMLを少し変更しました。 ここで、プレースホルダ<div> … </div>を作成しました。ここで、エントリポイントJavaクラスを使用してコンテンツを挿入します。 それでは、Javaファイル src/com.finddevguides/HelloWorld.java の内容を以下に示します。
package com.finddevguides.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
public class HelloWorld implements EntryPoint {
public void onModuleLoad() {
HTML html = new HTML("<p>Welcome to GWT application</p>");
RootPanel.get("gwtContainer").add(html);
}
}
ここでは、基本的なwidgest HTMLを作成し、id = "gwtContainer"を持つdivタグ内に追加しました。 今後の章では、さまざまなGWTウィジェットについて学習します。
すべての変更が完了したら、link:/gwt/gwt_create_application [GWT-アプリケーションの作成]の章で行ったように、アプリケーションをコンパイルして開発モードで実行します。 すべてがあなたのアプリケーションでうまくいけば、これは次の結果を生成します-
WARファイルを作成する
これでアプリケーションが正常に動作し、warファイルとしてエクスポートする準備が整いました。
次の手順に従ってください-
- プロジェクトの war ディレクトリに移動します C:\ workspace \ HelloWorld \ war
- warディレクトリ内で使用可能なすべてのファイルとフォルダーを選択します。
- 選択したすべてのファイルとフォルダーを_HelloWorld.zip_というファイルに圧縮します。
- _HelloWorld.zip_の名前を_HelloWorld.war_に変更します。
WARファイルを展開する
- Tomcatサーバーを停止します。
- _HelloWorld.war_ファイルを* tomcatインストールディレクトリ> webappsフォルダーにコピーします。*
- Tomcatサーバーを起動します。
- webappsディレクトリ内を見てください。 helloworld フォルダーが作成されているはずです。
- これで、HelloWorld.warがTomcat Webサーバールートに正常にデプロイされました。
アプリケーションを実行
WebブラウザーでURLを入力します: http://localhost:8080/HelloWorld アプリケーションを起動します
サーバー名(localhost)とポート(8080)は、Tomcatの構成によって異なる場合があります。