sitelink1 | |
---|---|
sitelink2 | |
sitelink3 | http://1 |
extra_vars6 | ko |
jpetstore를 포함한 spring2.0 다운로드
먼저, http://www.springframework.org 에서 "spring-framework-2.0-with-dependencies.zip"를 다운로드 한다. 그래야만 sample이 포함되어 있다.
"spring-framework-2.0-with-dependencies.zip" 다운받아 압축을 풀어주고, sample/jpetstore로 이동해 보면 다음과 같은 디렉토리 구조를 볼 수 있다.
MySQL 설정
JDK1.5.x, Ant1.6.x, Tomcat5.x, MySQL5.x 이 설치된 가정하에 진행하는 것이므로 더 진행해 보기 전에 필요한 소프트웨어를 설치하기 바란다. 설치가 완료되었으면 데이터 베이스로 MySQL을 사용할 것임으로 jdbc.properties 를 셋팅해 주어야 한다.
먼저, MySQL의 명령을 수행하여 jpetstore 데이터베이스를 생성한다.
create database jpetstore;
그리고 jpetstore 데이터베이스에 테이블을 생성하고 데이터를 입력해야 함으로 sample/jpetstore/db 디렉토리의 mysql 디렉토리로 이동하여 "jpetstore-mysql-schema.sql" 를 통해서 테이블을 생성하고, "jpetstore-mysql-dataload.sql"를 이용하여 필요한 레코드를 입력한다.
그리고, jpetstore에서 jdbc 설정을 해 주어야 한다. jpetstore/war/WEB-INF 디렉토리에 "jdbc.properties" 파일을 각자의 MySQL 설정에 맞게 수정해 준다.
이렇게 따라가는 순서는 jpetstore/war/WEB-INF 디렉토리에 web.xml을 보면 다음과 같은 셋팅이 존재한다.
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/dataAccessContext-local.xml /WEB-INF/applicationContext.xml </param-value> <!-- <param-value> /WEB-INF/dataAccessContext-jta.xml /WEB-INF/applicationContext.xml </param-value> --> </context-param>
여기서 /WEB-INF/applicationContext.xml 을 열어보면 bean 엘리먼트의 다음 셋팅으로 jdbc를 설정할 수 있게 된다.
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>WEB-INF/mail.properties</value> <value>WEB-INF/jdbc.properties</value> </list> </property> </bean>
따라서 jdbc.propties를 알맞게 수정해 주고 다음 과정을 진행한다.
패키징 및 war 배치
윈도우 명령 프롬프트에서 spring-framework-2.0/sample/jpetstore 디렉토리로 이동하여 다음 명령을 실행한다. Ant가 설치되어 있다고 가정함으로 build.xml 파일을 이용한 Ant를 실행한다.
ant warfile
이렇게하면, 소스 파일이 컴파일되고 해당 classes 들이 jar 파일로 묶여 jpetstore/war/WEB-INF/lib 디렉토리에 필요한 jar과 함께 생성되면, jpetstore/dist 디렉토리에 최종적으로 "jpetstore.war" 파일이 생성된다.
이제 모든 jpetstore 설치과정은 끝이났다. 실제로 Tomcat5.x 에 jpetstore.war를 배치하고 실행을 시켜보자. 그리고 http://localhost:8080/jpetstore 로 확인해 보면 다음과 같은 화면을 볼 수 있다.