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
470
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
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
620
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
The Cult of Friendly URLs
andyhume
79
7k
Tell your own story through comics
letsgokoyo
1
1.1k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
840
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
BBQ
matthewcrist
90
10k
Practical Orchestrator
shlominoach
192
12k
Mind Mapping
helmedeiros
1
400
How to Talk to Developers About Accessibility
jct
2
570
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ͷίϯηϓτͦ ͷ··
ࠓڵຯͬͨਓੋඇҰ ͞ΘͬͯΈ͍ͯͩ͘͞ʂ