SAStruts + PostgreSQL のスクラッチからの環境構築手順 - Procedure to Prepare Development Environment of SAStruts + PostgreSQL from scratch
導入 - Introduction
以下の環境構築の手順を書きます。また、都合上全て英語で書いてあります。 - I'll write a procedure to prepare the following development environment. And it's written in English for certain reasons.
- Java SE 6
- Tomcat 6.0
- Eclipse 3.5.0
- PostgreSQL 8.4.1
- 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
- Go "http://www.j2ee.me/javase/ja/6/download.html"
- Download "JDK 6 Update xx with Java EE"
- Executer the installer
Tomcat
- Go "http://tomcat.apache.org/"
- Go the link of Tomcat 6.x
- In "Binary Distributions", select "Windows Service Installer"
- Execute the downloaded file
- Click "Next >"
- Agree the Tomcat's license
- Click "Next >"
- Chose "Destination Folder" (ex. "C:\Tomcat6.0") and click "Next >"
- Decide port used by Tomcat, user name, and password, and click "Next >"
- Select JRE (ex. "C:\Program Files\Java\jre1.6.0_07") and click "Install"
- Check out "Run Apache Tomcat" and "Show Readme", and click "Finish"
Plugins of Eclipse
- Help > Install New Software...
- In Install, click "Add...",
- Set "Name" as "Seasar Plugin 3.2" and "Location" as "http://eclipse.seasar.org/updates/3.2/", and click "OK"
- Choose plugins, DbLauncher and Sysdeo/SQLI Tomcat Launch
- In Install, click "Add...",
- Set "Name" as "Seasar Plugin 3.3" and "Location" as "http://eclipse.seasar.org/updates/3.3/", and click "OK"
- Choose plugins, Dolteng, Kijimuna, ResourceSynchronizer, and SAStrutsPlugin
- In Install, click "Add...",
- Set "Name" as "Subclipse 1.6.x" and "Location" as "http://subclipse.tigris.org/update_1.6.x", and click "OK"
- Choose plugin, Subclipse
- Click "OK" and reboot Eclipse
Setup tutorial of SAStruts
Introduction
The tutorial of SAStruts is provided by Seasar project. It is the good reference to develop.
Procedure
- Go "http://sastruts.seasar.org/download.html"
- Download latest "sa-struts-tutorial-xxx.zip" from "Super Agile Struts Tutorial"
- Extract downloaded file (ex. C:\workspace_study\sa-struts-tutorial-xxx)
- Boot Eclipse
- Decide workspace (ex. C:\workspace_study)
- File > New > Project > Others
- Right click the project
Work the tutorial
- Boot Eclipse
- Tomcat > Boot Tomcat
- Go "http://localhost:8080/sa-struts-tutorial"
Now you can use a tutorial.
Create Template Project by using Dolteng
PostgreSQL and pgAdmin
Install PostgreSQL
- Go "http://www.postgresql.jp/"
- Select "Downloads"
- Select installer and download it
- Execute installer
Install pgAdmin
- Go "http://www.pgadmin.org/"
- Select "Download"
- Select your OS (ex. "Windows")
- Select "pgAdmin v1.8.4"
- Select "pgadmin3-1.8.4.zip"
- Select a mirror
- 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.
- Boot pgAdmin
- Create database "test_dev"
- Do some create script for "test_dev"
- Create database "test_ut"
- Do some create script for "test_ut"
SAStruts cooperates with PostgreSQL
- Go "http://jdbc.postgresql.org/" and select Download
- In Supported Versions, download "8.4-701 JDBC 4" from "Version 8.4 Build 701" and "JDBC4"
- Add "postgresql-8.4-701.jdbc4.jar" to webapp/WEB-INF/lib on Eclipse
- Show properties of project and select Libraries
- Click "Add JARs..."
- Select "postgresql-8.4-701.jdbc4.jar" and click "OK"
- Open "src/main/resources/jdbc.dicon"
- Comment out a setting for H2
- Uncomment of a setting for PostgreSQL
- In tag
, set value as "jdbc:postgresql://localhost:5432/test_dev" - In tag
, set value as "[your_user]" - In tag
, set value as "[your_pw]"
- Open "src/main/resources/s2jdbc.dicon"
- Comment out "
h2Dialect" - Uncomment "
postgreDialect" - Change from "postgreDialect" to "postgre81Dialect"
- Comment out "
- Copy "src/main/resources/jdbc.dicon" to "src/main/resources/jdbc_ut.dicon"
- In tag
, set value as ""jdbc:postgresql://localhost:5432/test_ut""
- In tag
- (If you'd like to generate scaffold by using Dolteng) In Eclipse, select DatabaseView tab
- Click the project name
- Select "Configure Config..."
- Set "Name" as "PostgreSQL"
- Set "Driver Path" as "postgresql-8.4-701.jdbc4.jar"
- Set "UserId" and "Password" as your settings.
- Click "Test Connection", when it says "Connection Succeed", preparation of DB connection is finished.