29
Spring Boot and Groovy. What more do you need? Iván López - @ilopmar

GR8Conf 2015 - Spring Boot and Groovy. What more do you need?

Embed Size (px)

Citation preview

Spring Boot and Groovy. What more do you need?

Iván López - @ilopmar

Hello!I am Iván López

@ilopmar

http://greachconf.com@madridgug

What isSpring Boot?

Spring Boot

▷ Fast bootstrap for Spring applications

▷ Opinionated framework (convention over configuration)

▷ Total integration with Spring ecosystem

Why is different?

▷ Non-functional requirements

▷ No XML/Code generation

▷ Groovy!

▷ Stand-alone applications

▷ Micro-services

What do I need to install it?

▷ Java 6+

▷ GVM: http://gvmtool.net

▷ Download it

Spring Boot CLI

1.DemoSpring Boot CLI

What happened?import org.springframework.boot.SpringApplicationimport org.springframework.boot.autoconfigure.EnableAutoConfigurationimport org.springframework.web.bind.annotation.RequestMappingimport org.springframework.web.bind.annotation.RestController @Grab('org.springframework.boot:spring-boot-starter-web:1.2.3.RELEASE')@EnableAutoConfiguration@RestControllerclass ThisWillActuallyRun {   @RequestMapping("/") String home() { 'Hello GR8Conf!' }   static void main(String[] args) { SpringApplication.run ThisWillActuallyRun, args }}

What happened?import org.springframework.boot.SpringApplicationimport org.springframework.boot.autoconfigure.EnableAutoConfigurationimport org.springframework.web.bind.annotation.RequestMappingimport org.springframework.web.bind.annotation.RestController @Grab('org.springframework.boot:spring-boot-starter-web')@EnableAutoConfiguration@RestControllerclass ThisWillActuallyRun {   @RequestMapping("/") String home() { 'Hello GR8Conf!' }   static void main(String[] args) { SpringApplication.run ThisWillActuallyRun, args }}

@EnableAutoConfiguration

▷ Tries to configure automatically the app

▷ Use the .jars on our classpath

▷ It goes away when we define our beans

Starters

▷ Standard POMs

▷ Recommended dependencies

▷ Transitive dependencies management

Startersactuator

amqp

aop

batch

data-elasticsearch

data-mongodb

groovy-templates

integration

jdbc

redis

remote-shell

security

websockets

...

Alright. How do I start?

▷ http://start.spring.io

▷ Maven/Gradle

▷ Java/Groovy

▷ JDK version (6, 7 & 8)

▷ Starters

Project structure$ tree.├── build.gradle└── src ├── main │   ├── groovy │   │   └── eu │   │   └── gr8conf │   │   └── DemoApplication.groovy │   └── resources │   ├── application.properties │   ├── static │   └── templates └── test └── groovy └── eu └── gr8conf └── DemoApplicationTests.groovy

spring-boot-starter-actuator

▷ Non-functional requirements

▷ Metrics

▷ Health-checks

Ready for production

▷ Spring boot CLIspring jar my-app.jar app.groovyjava -jar my-app.jar

▷ Gradle./gradlew buildjava -jar build/libs/my-app-0.0.1.jar

“Make jar not war

- Josh Long (@starbuxman)

Configuration

▷ application.properties / application.yml

▷ Override propertiesjava -jar app.jar --server.port=8181

▷ @ConfigurationProperties

Logging

▷ Logback by default

▷ Groovy configuration: logback.groovy

▷ @groovy.util.logging.Slf4j

2.Demo

What about Grails?

▷ Grails 3 built on top of Spring Boot

▷ Hybrid projects

And the bad things?

▷ It's Spring (for good and for bad)

▷ Annotation Driven Development

▷ Documentation

3.Summary

Let’s review some concepts

Fast bootstrap Spring applications

Future of Spring Framework

Micro-services

Gaining a lot oftraction

Gradle integration Groovy

Thanks!Any questions?

@ilopmar

[email protected]

https://github.com/lmivan

Iván López

http://kcy.me/23j7w