Overview
The Juneau integration component for Spring Boot consists of the following classes:
- {@link oajr.springboot.annotation.JuneauRestRoot}
- {@link oajr.springboot.JuneauRestInitializer}
- {@link oajr.springboot.SpringRestResourceResolver}
A typical Spring Boot application can use the {@link oajr.springboot.JuneauRestInitializer} to find
and register Juneau REST servlets via the {@link oajr.springboot.annotation.JuneauRestRoot} annotation.
@SpringBootApplication
@Controller
public class App {
public static void main(String[] args) {
new SpringApplicationBuilder(App.class)
.initializers(new JuneauRestInitializer(App.class))
.run(args);
}
/** Our root resource */
@Bean @JuneauRestRoot
public RootResource getRootResource() {
return new RootResource(); // A subclass of RestServlet.
}
}
The initializer will search for Spring beans annotated with the @JuneauRestRoot annotation identifying it
as a top-level servlet to be deployed in the Spring Boot web container.
Another option is to use the @JuneauRestRoot annotation on your Spring Boot source class like so:
@SpringBootApplication
@Controller
@JuneauRestRoot(servlets=RootResource.class)
public class App {
public static void main(String[] args) {
new SpringApplicationBuilder(App.class)
.initializers(new JuneauRestInitializer(App.class))
.run(args);
}
}
The root servlets are given an instance of {@link oajr.springboot.SpringRestResourceResolver} which allows
for child resources to be defined as injectable Spring beans.
The {@doc juneau-examples-rest-springboot} section describes how the Examples REST application is deployed
using Spring Boot and quickly deployable as an online application using Heroku.