몇일 전에 appfuse-light(appfuse-light-struts-ibatis-1.8-beta)를 설치해보았다. 설치 내용을 정리한다.
1 AppFuse 소개
다음은 AppFuseDefinition의 내용을 발췌한 것이다.
AppFuse is a Framework
This is sort of the 10,000 foot view of what AppFuse is. It is a structure in which web applications of a variety of types and sizes are created.
AppFuse is a Directory Structure
One of many features of AppFuse is the way it logically separates code into its appropriate locations based on function. Persistence code belongs in src/dao/, manager code in src/service/, controller code in src/web/ and of cource testing code in test/**/.
AppFuse is a Build File
The build.xml file makes for a nice way to create, build, test, package, deploy webapps. It also nicely handles changing dependancies and maintaining properties that may be different in development than in production.
AppFuse is a Sample Application
AppFuse is an example of how to use and integrate many Java technologies while following best practices. There are examples of how to do everything from performing CRUD opperations from your view all the way to the persistence layer to adding a filter to your webapp. Because the common things that are needed in basically all web applications are already in AppFuse, you will only need to figure out how to do the parts that make your webapp unique.
Figure 1 illustrates the conceptual design of a typical AppFuse application
2 설치(appfuse-light-struts2-ibatis-1.8-beta)
2.1 환경 설정
설치 전 아래의 환경이 세팅되어 있어야 한다. 내가 appfuse-light를 설치한 환경은 JPetStore 데모 설치 (iBATIS 또는 Spring 샘플)내용 중 1~5와 동일하다.
- J2SE 1.4.2 이상을 설치하고 설치 디렉토리를 가리키는 JAVA_HOME 환경변수를 셋팅한다.
- Ant 1.6.2 이상을 설치하고 ANT_HOME 환경변수를 셋팅한다.
- Tomcat 4.1.x 이상(추천되는 버전은 5.0.28)을 설치하고 톰캣 설치 디렉토리를 가리키는 CATALINA_HOME 환경변수를 셋팅한다.
- MySQL 3.23.x 이상(추천되는 버전은 4.1.7)을 설치한다.
- junit3.8.1 이상 버전에서 junit.jar를 $ANT_HOME/lib로 복사한다.
2.2 파일 다운로드
AppFuse-light 1.8-beta 다운로드 페이지에서 전체 샘플이 포함된 appfuse-light-all-1.8-beta.zip를 다운로드 하던지 원하는 파일을 다운로드한다. 여기서는 appfuse-light-struts-ibatis-1.8-beta.zip를 다운로드하여 설치한다. 파일이 다운로드되면 압축을 푼다. 아래는 D 드라이브의 Temp 디렉토리에 압축을 푼 모습이다.
total 54
0 ./ 12 LICENSE.txt 17 build.xml 0 src/
0 ../ 7 README.txt 0 lib/ 0 target/
0 .settings/ 1 build.properties 14 pom.xml 3 tomcat.xml
2.3 MySQL 사용을 위한 몇가지 변경 사항
AppFuse는 PostgreSQL을 기본 데이터베이스로 사용한다. MySQL을 사용하기 위해서는 몇가지 변경 사항을 적용하여야 한다.
jdbc.property 변경
D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\src\main\resources\jdbc.properties 파일을 다음과 같이 편집하여 저장한다.
jdbc.url=jdbc:mysql://localhost/appfuse_light?createDatabaseIfNotExist=true
jdbc.username=root
jdbc.password=xxxxxxxx
create-mysql 생성
D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\src\main\java\org\appfuse\dao\ibatis\create-mysql.sql 파일을 새로 만들고 다음과 같이 편집하여 저장한다.
drop table IF EXISTS app_user_sequence;
create table app_user_sequence (id int not null) type=MYISAM;
insert into app_user_sequence values(0);
build.xml 변경
D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\build.xml 파일을 열어 데이터베이스 테이블 생성 타겟의 내용을 다음과 같이 mysql 을 사용하도록 변경한다. 여기서 mysql-connector-java-5.1.0-bin.jar의 위치는 상황에 맞게 변경하던지 해당 위치에 MySql JDBC Driver를 복사해놓도록 해야한다.
<target name="createdb" description="Create database tables">
<sql driver="${jdbc.driverClassName}" url="${jdbc.url}"
userid="${jdbc.username}" password="${jdbc.password}">
<fileset dir="${basedir}">
<include name="src/**/create-mysql.sql"/>
</fileset>
<classpath refid="compile.classpath"/>
<classpath>
<pathelement location="${basedir}/lib/mysql-connector-java-5.1.0-bin.jar" />
</classpath>
</sql>
</target>
applicationContext-ibatis.xml
D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\src\main\webapp\WEB-INF\applicationContext-ibatis.xml 파일을 열어 userIncrementer 부분을 다음과 같이 변경하도록 한다.
<property name="dataSource" ref="dataSource"/>
<property name="incrementerName" value="app_user_sequence"/>
<property name="columnName" value="id" />
</bean>
2.4 어플리케이션 배포
커맨드 프롬프트에 ant deploy를 입력하여 배포한다.
Buildfile: build.xml
[mkdir] Created dir: D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\target\classes
[javac] Compiling 10 source files to D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\target\classes
[javac] Note: D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\src\main\java\org\appfuse\web\UserAction.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[mkdir] Created dir: D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\target\test\classes
[javac] Compiling 6 source files to D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\target\test\classes
[copy] Copying 3 files to D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\target\classes
[mkdir] Created dir: D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\target\jars
[copy] Copying 23 files to D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\target\jars
[copy] Copying 105 files to C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\appfuse-light
[copy] Copying 24 files to C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\appfuse-light\WEB-INF\classes
[copy] Copying 22 files to C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\appfuse-light\WEB-INF\lib
Total time: 18 seconds
D:\Temp\appfuse-light-struts2-ibatis-1.8-beta>
2.5 테이블 생성
커맨드 프롬프트에 ant createdb를 입력하여 배포한다.
Buildfile: build.xml
[sql] Executing resource: D:\Temp\appfuse-light-struts2-ibatis-1.8-beta\src\main\java\org\appfuse\dao\ibatis\create-mysql.sql
[sql] 5 of 5 SQL statements executed successfully
Total time: 3 seconds
D:\Temp\appfuse-light-struts2-ibatis-1.8-beta>
2.6 Tomcat 시작 및 테스트
톰캣을 시작한 후 http://localhost:8080/appfuse-light 로 접속한다.
3 참고 사이트
- Raible's Wiki (http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuse_ko)
- AppFuse 2 - Confluence (http://appfuse.org/)
- AppFuse Quick Start (http://raibledesigns.com/wiki/Wiki.jsp?page=AppFuseQuickStart_ko)
- AppFuse Articles (http://raibledesigns.com/wiki/Wiki.jsp?page=Articles)
- appfuse-light 프로젝트 홈 (https://appfuse-light.dev.java.net/)
- appfuse-light 1.8-beta 다운로드 (https://appfuse-light.dev.java.net/servlets/ProjectDocumentList?folderID=7353&expandFolder=7353&folderID=7353)
- Equinox (a.k.a. AppFuse Light) 1.7.1 (http://raibledesigns.com/rd/entry/equinox_a_k_a_appfuse1)
Posted by Mr.朴


