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 is
Spring 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.
Demo
Spring Boot CLI
What happened?
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
 
@Grab('org.springframework.boot:spring-boot-starter-web:1.2.3.RELEASE')
@EnableAutoConfiguration
@RestController
class ThisWillActuallyRun {
 
@RequestMapping("/")
String home() {
'Hello GR8Conf!'
}
 
static void main(String[] args) {
SpringApplication.run ThisWillActuallyRun, args
}
}
What happened?
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
 
@Grab('org.springframework.boot:spring-boot-starter-web')
@EnableAutoConfiguration
@RestController
class 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
Starters
actuator
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 CLI
spring jar my-app.jar app.groovy
java -jar my-app.jar
▷ Gradle
./gradlew build
java -jar build/libs/my-app-0.0.1.jar
“Make jar not war
- Josh Long
(@starbuxman)
Configuration
▷ application.properties / application.yml
▷ Override properties
java -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 of
traction
Gradle integration Groovy
Thanks!
Any questions?
@ilopmar
lopez.ivan@gmail.com
https://github.com/lmivan
Iván López
http://kcy.me/23j7w

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