{title:'Deployment', updated:'9.0.0'}

REST resources are deployed in the following ways:

- Deployed in a J2EE container as a servlet.
- Deployed in a Spring Boot environment as a servlet.
- Deployed as a child of another REST resource.

When deployed in a J2EE container, you MUST extend from one of the servlet classes.

- When deployed as a child of another resource, you MAY extend from one of the servlet classes but it's not necessary. The only requirement is that the class be annotated with @Rest and have one of the following constructors if they aren't already Spring Beans:
  - public T()
  - public T(RestContext.Builder)

Deployment in a servlet container is typically done by adding a servlet entry for the top-level resources to the JEE web.xml.

Deployment in a Spring Boot environment involves defining your top-level resources as Spring Beans. Top-level resources must extend from {@link oajr.springboot.BasicSpringRestServlet} or {@link oajr.springboot.BasicSpringRestServletGroup} so that Juneau can hook into the injection framework provided by Spring. Child resource CAN be defined as injected Spring Beans as well but it is not a requirement.

##### Example Spring Boot Configuration

| @SpringBootApplication | @Controller | public class SpringBootAppConfig { | | @Bean | public MyRootResources getRootResources() { | ... | } | | @Bean | public MyChildResource getMyChildResource() { | ... | } | | @Bean | public ServletRegistrationBean<Servlet> getRootServlet(RootResources rootResources) { | return new ServletRegistrationBean<>(rootResources, "/*"); | } | }