Last updated by admin 4 years ago
???????????????
???????????? Grails
????????????????? Grails ???? ???????????? target ??????????????????????????????????????????????:grails create-app
%PROJECT_HOME%
+ grails-app
+ conf ---> ????????????????? artifacts ???????????????? ???? data sources
+ controllers ---> ????????????????? controller artifacts
+ domain ---> ????????????????? domain classes
+ i18n ---> ?????????????????????????????????????? i18n
+ services ---> ????????????????? services
+ taglib ---> ????????????????? tag libraries
+ views ---> ????????????????? views
+ layouts ---> ????????????????? layouts
+ lib
+ spring ---> ?????????????????????? spring (?????????)
+ hibernate ---> ?????????????????????? hibernate (?????????)
+ war
+ WEB-INF??????????????????? (Data Source) (?????????)
??? target "create-app" ???????????????? (??????????? artifacts) ????????????????? Grails ??????????????????? "<..>/grails-app/conf" ????????????????????????????? HSQLDB ??? in-memory (???????????????? ????????????????????????????????????????) ?????????????????????????????????????????:class ApplicationDataSource {
@Property String url = "jdbc:hsqldb:mem:testDB"
@Property String driverClassName = "org.hsqldb.jdbcDriver"
@Property String username = "sa"
@Property String password = ""
}??????????????
??????????????????????????????????????????????? (???????????? "my-project") ???????? "cd my-project" ??????? target "grails create-domain-class" ????????????????????????????????????? ??????????????? artifact ??? persistent ?????????? properties ?????????????????????????????????? (????????????????????????????????????? GORM (Grails Object Relational Mapping) ):class Book {
@Property Long id
@Property Long version @Property String title
@Property String author
}new Book(author:"Stephen King",title:"The Shining").save() new Book(author:"James Patterson",title:"Along Came a Spider").save()
????????????????????????
????????????? controller ???????????????? Grails ???????????? ?????????????????????????????? (web request) ??? URL ???????????????????????????????????????????????? closure ????????????????? ????? target "grails generate-all" ?????????????????????????????? ?????????????????? "book" ???????? Grails ?????????????????????????????????????????????????????? CRUD ??????? ???????????.????? Grails
???????????????????????????????? Grails ???????????? ?????? target ????????grails run-app
http://localhost:8080/my-project/book/list
http://localhost:8080/my-project/book



