Installing in Eclipse

Follow these instructions to import the REST examples project using Spring Boot into Eclipse.

1. Download the juneau-examples-rest-springboot-{@property juneauVersion}.zip file from the downloads page (located in the binaries) and import it into your workspace as an existing project:
2. Select the archive file and import the project:
3. In your workspace, you should now see the following project:

The important elements in this project are:

- App.java - The entry point.
  This class creates and starts our microservice.
  Note that we're using the existing Spring Boot application logic for the microservice and we're retrieving our root resource as a spring bean.
  Only the top-level resource needs to be annotated with {@link oaj.rest.springboot.annotation.JuneauRestRoot @JuneauRestRoot}

  @SpringBootApplication @Controller public class App { public static void main(String[] args) { new SpringApplicationBuilder(App.class) .initializers(new JuneauRestInitializer(App.class)) .run(args); } @Bean @JuneauRestRoot public RootResources getRootResources() { return new RootResources(); } }

- RootResources.java - The top-level REST resource.
  This class routes HTTP requests to child resources:

  @RestResource( path="/*", title="Root resources", description="Example of a router resource page.", htmldoc=@HtmlDoc( widgets={ ContentTypeMenuItem.class, ThemeMenuItem.class }, navlinks={ "options: ?method=OPTIONS", "$W{ContentTypeMenuItem}", "$W{ThemeMenuItem}", "source: $C{Source/gitHub}/org/apache/juneau/examples/rest/$R{servletClassSimple}.java" }, aside={ "<div style='max-width:400px' class='text'>", " <p>This is an example of a 'router' page that serves as a jumping-off point to child resources.</p>", " <p>Resources can be nested arbitrarily deep through router pages.</p>", " <p>Note the <span class='link'>options</span> link provided that lets you see the generated swagger doc for this page.</p>", " <p>Also note the <span class='link'>sources</span> link on these pages to view the source code for the page.</p>", " <p>All content on pages in the UI are serialized POJOs. In this case, it's a serialized array of beans with 2 properties, 'name' and 'description'.</p>", " <p>Other features (such as this aside) are added through annotations.</p>", "</div>" } ), children={ HelloWorldResource.class, PetStoreResource.class, DtoExamples.class, ConfigResource.class, LogsResource.class, ShutdownResource.class } ) @SerializerConfig( // For testing purposes, we want to use single quotes in all the serializers so it's easier to do simple // String comparisons. quoteChar="'" ) public class RootResources extends BasicRestServletJenaGroup { // No code }

- juneau.cfg - The configuration file.
  Contains various useful settings.
  Can be used for your own resource configurations.
  Note that the Jetty configuration is not present.
  Also it's located in the classpath so that our microservice can be built as a single executable jar.

  #======================================================================================================================= # Basic configuration file for REST microservices # Subprojects can use this as a starting point. #======================================================================================================================= #======================================================================================================================= # REST settings #======================================================================================================================= [REST] # URL mappings to static files in the working directory or classpath. staticFiles = htdocs:files/htdocs # Stylesheet to use for HTML views. theme = servlet:/htdocs/themes/devops.css headerIcon = servlet:/htdocs/images/juneau.png headerLink = http://juneau.apache.org footerIcon = servlet:/htdocs/images/asf.png footerLink = http://www.apache.org favicon = $C{REST/headerIcon} header = <a href='$U{$C{REST/headerLink}}'> <img src='$U{$C{REST/headerIcon}}' style='position:absolute;top:5;right:5;background-color:transparent;height:30px'/> </a> footer = <a href='$U{$C{REST/footerLink}}'> <img src='$U{$C{REST/footerIcon}}' style='float:right;padding-right:20px;height:32px'/> </a>

At this point, you're ready to start the microservice from your workspace.