Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Grails 3で生まれ変わったGrailsの今 / Spring in Summer 2015
Search
Kazuki YAMAMOTO
September 02, 2015
1
440
Grails 3で生まれ変わったGrailsの今 / Spring in Summer 2015
「Spring in Summer ~ 夏なのにSpring」での発表資料です
http://www.springframework.jp/summer
Kazuki YAMAMOTO
September 02, 2015
Tweet
Share
More Decks by Kazuki YAMAMOTO
See All by Kazuki YAMAMOTO
今こそッ、始めようGrailsブートキャンプ!!!! / Grails Bootcamp for JGGUG
yamkazu
0
330
Grails 3でWeb APIを簡単に作ろう!
yamkazu
6
2.3k
Featured
See All Featured
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
0
37
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
sira's awesome portfolio website redesign presentation
elsirapls
0
86
30 Presentation Tips
portentint
PRO
1
160
Designing for humans not robots
tammielis
254
26k
The Pragmatic Product Professional
lauravandoore
37
7.1k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
140
The Cost Of JavaScript in 2023
addyosmani
55
9.4k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
60
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
63
35k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
250
Transcript
Grails3Ͱੜ·ΕมΘͬͨ Grailsͷࠓ @yamkazu
ࢁຊ थ • @yamkazu • JGGUG
None
ຊͷ༰ • Grails͓͞Β͍ • Grails 3ͷ৽ػೳ • σϞ
Grails͓͞Β͍
Grailsͱ • Graeme Rocherࢯ͕։ൃ • ϑϧελοΫͷWebϑϨʔϜϫʔΫ • Groovyϕʔε • Ruby
on RailsɺDjangoͱ͍ͬͨϑϨʔϜϫʔΫʹӨڹΛड͚͍ͯΔ • DRYʢDon't Repeat Yourselfʣ= ಉ͡هड़Λ܁Γฦ͞ͳ͍ • CoCʢConvention over Configurationʣ= ઃఆΑΓن • εΩϟϑΥϧσΟϯά • Java EE্Ͱಈ࡞
Grailsͷྺ࢙ 4QSJOH4PVSDFԼ 7.XBSF͕ 4QSJOH4PVSDFΛങऩ
4QSJOH4PVSDF͕ 1JWPUBMԼ 1JWPUBMଔۀ
OCI͕৽͍͠ϗʔϜ http://www.ociweb.com/resources/news/2015/04/15/april-2015-grails-web-framework-finds-home-oci
৽ϝϯόՃ&ืूத
Grailsͷத
= + +
σʔλΞΫηε αʔϏε ΞϓϦέʔγϣϯ ϓϨθϯςʔγϣϯ GrailsΛߏ͢Δཁૉ 63-Ϛοϐϯά ϑΟϧλ λάϦϒ ίϯτϩʔϥ Ϗϡʔ
αʔϏε JO υϝΠϯΫϥε Ξηοτ ςετ ϓϥάΠϯ εΩϟϑΥϧυ
ίϯτϩʔϥ class BookController { def index() { … render view:
'index' } }
Ϗϡʔ(GSP) <!DOCTYPE html> <html> <head> <meta name="layout" content="main"/> <title>Render Domain</title>
</head> <body> <table> <tr> <td>Name</td> <td>Age</td> </tr> <g:each in="${list}" var="person"> <tr> <td>${person.lastName}, ${person.firstName}</td> <td>${person.age}</td> </tr> </g:each> </table> </body> </html>
υϝΠϯΫϥε(GORM) class Book { String title Integer price static
constraints = { title(blank: false, maxSize: 20) price(min: 0) } } // 保存 new Book(title: "はじめてのGrails", price: 3000).save() // クエリ Book.list() Book.findByTitle("はじめてのGrails")
ςετ(Spock) @TestFor(Book) class BookSpec extends Specification { def "find book
by title"() { given: "Bookが1件保存" new Book(title: "test title", price: 3000).save() when: "Bookをタイトルで検索する" def book = Book.findByTtile("test title") then: "対象のBookが取得できている" book.title == "test title" book.price == 3000 } }
Grails 3
Grails 3ͷ֓ཁ • Spring BootΛϕʔεʹ࠶ߏங • GradleͰϏϧυγεςϜ͕Ұ৽ • ΞϓϦέʔγϣϯϓϩϑΝΠϧͷՃ •
ίϯτϩʔϥɺυϝΠϯΫϥεͳͲͷ͍ํ΄ͱΜ Ͳมߋͳ͠ • etc
Spring Boot
Spring Boot • Spring Boot 1.2Λϕʔεʹ࠶ߏங • ෦ΞϓϦέʔγϣϯαʔό • ࣮ߦՄೳJarϑΝΠϧ
• Spring BootSpringͷΤίγεςϜ͕ΑΓ׆༻͘͢͠ • ϞχλϦϯάͷ֦ு • Spring CloudΛ͍͍ͨ
Bootʹ͓ͤͰ͖Δͱ͜Ζ ͤͯGrailsࣗΛεϦϜԽ
ͦͷଞSpring Bootಋೖʹ ͏มߋ
Application.groovy import grails.boot.GrailsApp import grails.boot.config.GrailsAutoConfiguration class Application extends GrailsAutoConfiguration
{ static void main(String[] args) { GrailsApp.run(Application) } }
application.yml --- grails: profile: web codegen: defaultPackage: grails.sample.plugin.database.migration info: app:
name: '@info.app.name@' version: '@info.app.version@' grailsVersion: '@info.app.grailsVersion@' spring: groovy: template: check-template-location: false --- grails: mime: disable: accept: header:
ΠϯςάϨʔγϣϯςετ import grails.test.mixin.integration.Integration import spock.lang.Specification @Integration class BookSpec extends
Specification { def "count books"() { expect: Book.count() == 1 } }
None
buildscript { ext { grailsVersion = project.grailsVersion } repositories {
mavenLocal() maven { url "https://repo.grails.org/grails/core" } } dependencies { classpath "org.grails:grails-gradle-plugin:$grailsVersion" classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.1.1' classpath 'org.grails.plugins:database-migration:2.+' } } plugins { id "io.spring.dependency-management" version "0.4.0.RELEASE" } version "0.1" group "grails.sample.plugin.database.migration" apply plugin: "spring-boot" apply plugin: "war" apply plugin: "asset-pipeline" apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: "org.grails.grails-web"
None
None
maven/gradleͰ͓ೃછΈͷ σΟϨΫτϦߏʹมߋ
None
GGTS೦ͳ͕Β ݱࡏϝϯςφϯε ͞Ε͍ͯͳ͍
ͦͷଞGradleͷޮՌ • Ϗϧυ͕ߴʹͳͬͨ • ϚϧνϓϩδΣΫτ͕؆୯ʹ࣮ݱͰ͖Δ • Gradleͷطଘͷ֦ு͕༻Մೳʹͳͬͨ
ΞϓϦέʔγϣϯϓϩϑΝΠϧ
ΞϓϦέʔγϣϯϓϩϑΝΠϧ • ϓϩϑΝΠϧʹؚ·ΕΔͷ • ϓϩδΣΫτςϯϓϨʔτ • ϑΝΠϧςϯϓϨʔτ • ίϚϯυ(runɺpackageɺtestɺetc)
ϓϩϑΝΠϧϦϙδτϦ • GitͷϦϙδτϦͱͯ͠ཧ͞Ε͍ͯΔ • https://github.com/grails/grails-profile-repository/ • ݱࡏެ։͞Ε͍ͯΔϓϩϑΝΠϧ·ͩΘ͔ͣ • webɺweb microɺweb
apiɺpluginɺweb plugin • ࠓޙʹظ
ͦͷଞͷมߋ
Logback͕σϑΥϧτʹ appender('STDOUT', ConsoleAppender) { encoder(PatternLayoutEncoder) { pattern = "%level %logger
- %msg%n" } } root(ERROR, ['STDOUT']) logger('org.hibernate.type.descriptor.sql.BasicBinder', TRACE) logger('org.hibernate.SQL', DEBUG)
Geb͕σϑΥϧτϓϥάΠϯʹ @Integration class HomeSpec extends GebSpec { void "Test
the home page renders correctly"() { when:"The home page is visited" go '/' then:"The title is correct" $('title').text() == "Welcome to Grails" } }
σϞ
Grails 3ͷ࣮ࡍ • Grails 2.x͔ΒͷҠߦ͍ͨΜ • υΩϡϝϯτͱҠߦϓϥάΠϯͰؤுΔ • Grails 3Ͱͳ͘ͳͬͨػೳ͕͕͋ͬͨඞཁͳػೳ෮׆
• ίϛϡχςΟ͔ΒͷϑΟʔυόοΫ • ϓϥάΠϯ͕গͳ͍ • ओཁͳϓϥάΠϯग़ἧ͍ͭͭ͋Δ • Spring Security PluginઌM1͕ϦϦʔε • ·ͩόάଟΊͳؾ • ΄ΜͱΜͲͷ߹ϫʔΫΞϥϯυଘࡏ͢Δ
ࠓޙͷϦϦʔε༧ఆ • Grails 3.1 • New feature planned include: •
More flexible profile repository support • multiple repositories • custom repositories • altering current repo • REST Improvements • REST profile • JSON builder views • Renderer convention • Removal of org.json and GSon to unify around JsonBuilder • Namespaced marshallers • UrlMappings for members and collections • AngularJS / SPA framework support • AngularJS profile https://github.com/grails/grails-core/wiki/Roadmap
·ͱΊ • GradeɺSpringͳͲطଘͷΤίγεςϜΛϕʔ εʹੜ·ΕมΘͬͨ • ͜ΕΒΛͬͨ։ൃΛ͞ΒʹՃͤ͞Δϓ ϥοτϑΥʔϜʹ্͕͍ͬͯΔ • DRYɺCoCͳͲطଘͷGrailsͷίϯηϓτͦ ͷ··
ࠓڵຯͬͨਓੋඇҰ ͞ΘͬͯΈ͍ͯͩ͘͞ʂ