Get ahead
VMware offers training and certification to turbo-charge your progress.
Learn moreSpring Boot 0.5.0.M5 is available in the Spring repo. Instructions for installing and using are on the project website or in github. Loads of new features including:
@Grab
usage (see example below)SpringApplicationBuilder
with support for, amongst other things, application context hierarchiesPropertiesLauncher
that can launch a Java application from properties discovered at runtime (e.g. to set up a classpath from a lib directory)As a taster, here is an example usage of SpringApplicationBuilder
in Java to build an application with a parent context (useful if you want to run more than one app from the same code):
@Configuration
@EnableAutoConfiguration
public class Server {
public static void main(String[] args) {
new SpringApplicationBuilder(Parent.class)
.child(Server.class)
.profiles("server")
.run(args);
}
// ... @Bean definitions follow
}
The Parent.class
above is a shared parent context that can be reused for other apps in the same module.
And here's an example of the abbreviated @Grab
in a Groovy app (the group and version information are added automatically):
@Grab("spring-boot-starter-actuator")
@RestController
class Example {
@RequestMapping("/")
String home() {
[message: 'Hello World']
}
}
This app runs on its own, e.g. in the current directory if you use the spring
shell script to launch it:
$ spring run app.groovy
... (app starts up)
Visit http://localhost:8080/ in a browser and then try http://localhost:8080/metrics.