Engineering
Releases
News and Events

Spring Boot 0.5.0.M5 Released

Spring 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:

  • Autoconfigure support for JMS, AMQP, AOP, Mobile, MongoDB
  • Simplified @Grab usage (see example below)
  • A test command for Groovy scripts (supporting JUnit and Spock, more detail coming on that in a blog from Greg)
  • A new SpringApplicationBuilder with support for, amongst other things, application context hierarchies
  • A new PropertiesLauncher 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.

comments powered by Disqus