Follow these instructions to create a new template project in Eclipse.
Download the my-springboot-microservice-{@property juneauVersion}.zip file from the downloads page
(located in the binaries) and import it into your workspace as an existing project:
Select the archive file and import the project:
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@Controllerpublic class App {
public static void main(String[] args) {
new SpringApplicationBuilder(App.class)
.initializers(new JuneauRestInitializer(App.class))
.run(args);
}
@Bean @JuneauRestRootpublic RootResources getRootResources() {
return new RootResources();
}
}
RootResources.java - The top-level REST resource.
This class routes HTTP requests to child resources.
This is identical to the Jetty example.
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]# Comma-delimited list of key-value pairs that represent locations of static files that can be served up by your @Rest-annotated
# classes. These are static files that are served up by the servlet under the specified sub-paths.
# For example, given the following setting...
# staticFiles = htdocs:my-docs,styles/my-styles
# ...the URI "/servletPath/htdocs/javadoc.css" resolves to the path "/my-docs/javadoc.css".
# This path can be relative to the working directory, classpath root, or package of your resource class.
# Used by the BasicRestConfig interface that defines the following value:
# staticFiles="$C{REST/staticFiles}"staticFiles = htdocs:htdocs
# Stylesheet to use for HTML views.
# Used by the BasicRestConfig interface that defines the following value:
# stylesheet="$C{REST/theme,servlet:/htdocs/themes/devops.css}"theme = servlet:/htdocs/themes/devops.css# Various look-and-feel settings used in the BasicRestConfig interface.headerIcon = servlet:/htdocs/images/juneau.pngheaderLink = http://juneau.apache.orgfooterIcon = servlet:/htdocs/images/asf.pngfooterLink = http://www.apache.orgfavicon = $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.