読者です 読者をやめる 読者になる 読者になる

bekkou68の日記

開発しているサービス, IT技術, 英語など。

SAStruts + PostgreSQL のスクラッチからの環境構築手順 - Procedure to Prepare Development Environment of SAStruts + PostgreSQL from scratch

SAStruts PostgreSQL

導入 - Introduction

以下の環境構築の手順を書きます。また、都合上全て英語で書いてあります。 - I'll write a procedure to prepare the following development environment. And it's written in English for certain reasons.

  1. Java SE 6
  2. Tomcat 6.0
  3. Eclipse 3.5.0
    1. DbLauncher 0.1.0
    2. Sysdeo/SQLI Tomcat Launch 3.2.1
    3. Dolteng 0.38.0
    4. Kijimuna 1.1.14
    5. ResourceSynchronizer 0.0.5
    6. SAStrutsPlugin 0.0.14
    7. Subclipse 1.6.5
  4. PostgreSQL 8.4.1
  5. pgAdmin 1.8.4

さらに、テスト環境として、開発用 DB と単体テスト用 DB の二つを使うことを想定します。 - Furthermore, assume that we use two databases which are for development and unit test as the test environment.

Java

  1. Go "http://www.j2ee.me/javase/ja/6/download.html"
  2. Download "JDK 6 Update xx with Java EE"
  3. Executer the installer

Tomcat

  1. Go "http://tomcat.apache.org/"
  2. Go the link of Tomcat 6.x
  3. In "Binary Distributions", select "Windows Service Installer"
  4. Execute the downloaded file
    1. Click "Next >"
    2. Agree the Tomcat's license
    3. Click "Next >"
    4. Chose "Destination Folder" (ex. "C:\Tomcat6.0") and click "Next >"
    5. Decide port used by Tomcat, user name, and password, and click "Next >"
    6. Select JRE (ex. "C:\Program Files\Java\jre1.6.0_07") and click "Install"
    7. Check out "Run Apache Tomcat" and "Show Readme", and click "Finish"

Eclipse

  1. Go "http://www.eclipse.org/"
  2. Go the link of "Downloads"
  3. Select "Eclipse IDE for Java EE Developers"
  4. Extract downloaded file (ex. under "C:\")
  5. Boot Eclipse (\eclipse\eclipse.exe)
  6. Set "Workspace" (ex. "C:\workspace_study")
  7. Check "Use this as the default and do not ask again"

Plugins of Eclipse

  1. Help > Install New Software...
  2. In Install, click "Add...",
    1. Set "Name" as "Seasar Plugin 3.2" and "Location" as "http://eclipse.seasar.org/updates/3.2/", and click "OK"
    2. Choose plugins, DbLauncher and Sysdeo/SQLI Tomcat Launch
  3. In Install, click "Add...",
    1. Set "Name" as "Seasar Plugin 3.3" and "Location" as "http://eclipse.seasar.org/updates/3.3/", and click "OK"
    2. Choose plugins, Dolteng, Kijimuna, ResourceSynchronizer, and SAStrutsPlugin
  4. In Install, click "Add...",
    1. Set "Name" as "Subclipse 1.6.x" and "Location" as "http://subclipse.tigris.org/update_1.6.x", and click "OK"
    2. Choose plugin, Subclipse
  5. Click "OK" and reboot Eclipse

Apply Tomcat to Eclipse

Settings of Tomcat
  1. Window > Preferences... > Tomcat
    1. Set "Tomcat version" as "version 6.x"
    2. Set "Tomcat home" as "C:\apache-tomcat6.0"
    3. Set "Context declaration mode" as "Context file"
    4. Click "OK"
Edit the following files of Tomcat
  1. Edit "\conf\server.xml"
    1. Change from to
  2. Edit "\conf\context.xml"
    1. Uncomment

Setup tutorial of SAStruts

Introduction

The tutorial of SAStruts is provided by Seasar project. It is the good reference to develop.

Procedure
  1. Go "http://sastruts.seasar.org/download.html"
    1. Download latest "sa-struts-tutorial-xxx.zip" from "Super Agile Struts Tutorial"
    2. Extract downloaded file (ex. C:\workspace_study\sa-struts-tutorial-xxx)
  2. Boot Eclipse
  3. Decide workspace (ex. C:\workspace_study)
  4. File > New > Project > Others
    1. Select "Java Project" and click "Next >"
    2. Decide project name (ex. tutorial)
    3. In "Contents", choose "Create project from existing source"
    4. Directory as ex. "C:\sa-struts-tutorial-1.0.4-sp6\sa-struts-tutorial"
    5. Click "Finish"
  5. Right click the project
Work the tutorial
  1. Boot Eclipse
  2. Tomcat > Boot Tomcat
  3. Go "http://localhost:8080/sa-struts-tutorial"

Now you can use a tutorial.

Create Template Project by using Dolteng

  1. File > New > Project
  2. Dolteng > Dolteng Project click "Next >"
    1. Set "Project name" (ex. "template")
    2. Set "Root Package Name" (ex. "test")
    3. Choose "Presentation" as "SAStruts"
    4. Choose "Persistence" as "S2JDBC"

SVN

  1. In Navigator perspective, right click on project
  2. Team > Share Project...
  3. Select "SVN" and click "Next >"
  4. Set "Url" (depends on your SVN URL)
  5. Click "Finish"
  6. Set "User Name" and "Password" (depends on your SVN settings)
  7. Click "OK"

PostgreSQL and pgAdmin

Install PostgreSQL
  1. Go "http://www.postgresql.jp/"
  2. Select "Downloads"
  3. Select installer and download it
  4. Execute installer
Install pgAdmin
  1. Go "http://www.pgadmin.org/"
  2. Select "Download"
  3. Select your OS (ex. "Windows")
  4. Select "pgAdmin v1.8.4"
  5. Select "pgadmin3-1.8.4.zip"
  6. Select a mirror
  7. Execute a downloaded installer and install pgAdmin
Create Database

Assuming that, database "test_dev" is used for development and database "test_ut" is used for unit test.

  1. Boot pgAdmin
  2. Create database "test_dev"
  3. Do some create script for "test_dev"
  4. Create database "test_ut"
  5. Do some create script for "test_ut"

SAStruts cooperates with PostgreSQL

  1. Go "http://jdbc.postgresql.org/" and select Download
    1. In Supported Versions, download "8.4-701 JDBC 4" from "Version 8.4 Build 701" and "JDBC4"
    2. Add "postgresql-8.4-701.jdbc4.jar" to webapp/WEB-INF/lib on Eclipse
    3. Show properties of project and select Libraries
    4. Click "Add JARs..."
    5. Select "postgresql-8.4-701.jdbc4.jar" and click "OK"
  2. Open "src/main/resources/jdbc.dicon"
    1. Comment out a setting for H2
    2. Uncomment of a setting for PostgreSQL
    3. In tag , set value as "jdbc:postgresql://localhost:5432/test_dev"
    4. In tag , set value as "[your_user]"
    5. In tag , set value as "[your_pw]"
  3. Open "src/main/resources/s2jdbc.dicon"
    1. Comment out "h2Dialect"
    2. Uncomment "postgreDialect"
    3. Change from "postgreDialect" to "postgre81Dialect"
  4. Copy "src/main/resources/jdbc.dicon" to "src/main/resources/jdbc_ut.dicon"
    1. In tag , set value as ""jdbc:postgresql://localhost:5432/test_ut""
  5. (If you'd like to generate scaffold by using Dolteng) In Eclipse, select DatabaseView tab
    1. Click the project name
    2. Select "Configure Config..."
    3. Set "Name" as "PostgreSQL"
    4. Set "Driver Path" as "postgresql-8.4-701.jdbc4.jar"
    5. Set "UserId" and "Password" as your settings.
    6. Click "Test Connection", when it says "Connection Succeed", preparation of DB connection is finished.

References

Super Agile Struts

Enjoy SAStruts!