Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Grails 3で生まれ変わったGrailsの今 / Spring in Summer 2015
Search
Kazuki YAMAMOTO
September 02, 2015
460
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Grails 3で生まれ変わったGrailsの今 / Spring in Summer 2015
「Spring in Summer ~ 夏なのにSpring」での発表資料です
http://www.springframework.jp/summer
Kazuki YAMAMOTO
September 02, 2015
More Decks by Kazuki YAMAMOTO
See All by Kazuki YAMAMOTO
今こそッ、始めようGrailsブートキャンプ!!!! / Grails Bootcamp for JGGUG
yamkazu
0
340
Grails 3でWeb APIを簡単に作ろう!
yamkazu
6
2.4k
Featured
See All Featured
Odyssey Design
rkendrick25
PRO
2
800
sira's awesome portfolio website redesign presentation
elsirapls
0
410
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
YesSQL, Process and Tooling at Scale
rocio
174
15k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Paper Plane
katiecoart
PRO
3
53k
エンジニアに許された特別な時間の終わり
watany
108
250k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
HDC tutorial
michielstock
2
870
The agentic SEO stack - context over prompts
schlessera
0
930
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ͷίϯηϓτͦ ͷ··
ࠓڵຯͬͨਓੋඇҰ ͞ΘͬͯΈ͍ͯͩ͘͞ʂ