Spring Roo! 간단한 프로젝트 만들기




Spring Roo~ 작년에 봤을 때는 듣보잡처럼 보였는데, 지금 보니깐 감동의 물결이 넘실거립니다.


설치에 대해서는 튜토리얼을 보면 되기 때문에 나중에 정리할 여유가 생기면 하기로 하고... 지금은 설치가 된 상태를 가정하여 작성합니다.




구동 환경


Spring Roo 1.1.4 RELEASE

Maven 2.2.1.RELEASE

STS 2.7.0 RELEASE (필수는 아님)




새로운 프로젝트 디렉토리를 생성하고 roo shell 을 실행시킵니다.


# mkdir RentShop

# cd RentShop

# roo


roo>





프로젝트를 생성합니다. 프로젝트 생성 시에는 최상위 패키지를 지정해야 합니다.


roo> project --topLevelPackage kr.co.vicki.roo.sample.rentshop




퍼시스턴스 레이어를 설정합니다. 프로바이더는 하이버네이트로, 데이터베이스는 테스트 용이므로 메모리 DB를 사용합니다.


roo> persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY




엔티티 클래스를 생성합니다. Car, Customer, Rent


roo> entity --class ~.domain.Car --testAutomatically

roo> field string --fieldName modelName --notNull

roo> field number --fieldName displacement --type java.lang.Integer --notNull 0


roo> entity --class ~.domain.Customer --testAutomatically

roo> field string --fieldName name --notNull


roo> entity --class ~.domain.Rent --testAutomatically

roo> field reference --fieldName car --type ~.domain.Car --notNull

roo> field number --fieldName period --type java.lang.Integer --notNull 0




컨트롤러를 생성합니다. 패키지를 지정가능합니다. 위에 엔티티 생성시에도 나왔던 '~' 는 프로젝트 생성 시 지정했던 topLevelPackage 를 의미합니다.


roo> controller all --package ~.web





이걸로 간단한 샘플 프로젝트는 끝이 났습니다. 톰캣을 띄워 확인합니다.


# mvn tomcat:run


....

2011. 7. 13 오전 1:03:51 org.apache.catalina.startup.Embedded start

정보: Starting tomcat server

2011. 7. 13 오전 1:03:51 org.apache.catalina.core.StandardEngine start

정보: Starting Servlet Engine: Apache Tomcat/6.0.29

2011. 7. 13 오전 1:03:51 org.apache.catalina.core.ApplicationContext log

정보: Initializing Spring root WebApplicationContext

2011. 7. 13 오전 1:03:53 org.apache.catalina.core.ApplicationContext log

정보: Initializing Spring FrameworkServlet '


RentShop


'

2011. 7. 13 오전 1:03:53 org.apache.coyote.http11.Http11Protocol init

정보: Initializing Coyote HTTP/1.1 on http-8080

2011. 7. 13 오전 1:03:53 org.apache.coyote.http11.Http11Protocol start

정보: Starting Coyote HTTP/1.1 on http-8080





위에 보이는 컨텍스트를 확인하여 생성된 프로젝트에 접속을 합니다.


http://localhost:8080/RentShop










먼가 투박해보이기는 하지만 CRUD 페이지가 뚝딱 만들어졌습니다.


아직 진가를 보여주기에는 부족해보이지만 실제로 Spring Roo 를 어딘가에 적용할지를 생각한다면... WOW 입니다~



댓글

가장 많이 본 글