Deploying a Spring Boot application to Liberty
You can enable Liberty to support a Spring Boot application.
About this task
To enable Liberty to support a Spring Boot
application, add the
springBoot-2.0 feature to
the server.xml file. When you deploy a Spring Boot application, Liberty disables the web container that is
embedded in the application and instead uses the Liberty web container. You can deploy one Spring
Boot application for each server configuration.
The following steps use an example to show how to deploy a Spring Boot application. You create a
Liberty server instance, deploy your Spring
Boot .jar application, and specify the default HTTP port for the server
instance. By default, Liberty deploys the
Spring Boot application with the default host configuration. The example uses the
hellospringboot.jar application and
9090 for the default HTTP
port. If you don't have a Spring Boot .jar application, see the Spring Boot
Run the server create helloserver command to create a server and name it
This command creates the /usr/servers/helloserver/apps directory.
Enable the version of the Liberty
springBootfeature that your application requires.For example, if your application uses Spring Boot 1.5.8, add the
springBoot-1.5feature to the
featureManagerelement of the server.xml file.. If your application uses Spring Boot 2.0.1, enable the
springBoot-2.0feature. The hellospringboot.jar application uses the
spring-boot-starter-webfeature, which also requires you to enable a
<!-- Enable features --> <featureManager> <feature>springBoot-1.5</feature> <feature>servlet-3.1</feature> </featureManager>
- Copy the hellospringboot.jar application into the /usr/servers/helloserver/apps directory that was created by the server create command.
Choose to deploy an application with either the server.xml application
configuration or with the dropins folder as shown in the following
- Configure the application by updating the server.xml file that was created
by the server create command.
Define the application with a
springBootApplicationelement or an
<application type="spring" location="hellospringboot.jar"/>
- If you choose not to update the server.xml file, use Liberty dropins support instead.
- Copy the hellospringboot.jar file to the /usr/servers/helloserver/dropins/spring/hellospringboot.jar directory.
- The spring subdirectory within the dropins subdirectory keeps the existing .jar or .war extension.
- Use the .spring extension when you copy the application directly to the dropins subdirectory.
- Configure the application by updating the server.xml file that was created by the server create command.
Configure the HTTP port for the default host to 9090 by replacing the
httpPort="9080"attribute value with an
<httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9090" />
Start the server in the foreground.
server run helloserver
Test the application at the
After you no longer need the server, run the server stop command.
server stop helloserver