Building and deploying Spring Boot applications

You can build your Spring Boot applications for use in CICS® with Maven or with Gradle.

Building Spring Boot applications as WAR or JAR files

You can build Spring Boot applications as a web application archive (WAR) or a Java™ Archive (JAR) file. Build your Spring boot application as a WAR if you are looking to integrate Spring Framework transactional management or Spring Boot Security in CICS. See Table 1. When built as a WAR, a Spring Boot application can be deployed and managed by using CICS bundles in the same way as other CICS Liberty applications. When built as a JAR the springBoot-1.5 or springBoot-2.0 feature must be installed and the JAR must be deployed by using either a Liberty application element with the type="spring" attribute or by using the dropins directory. However, if you have an existing application that you simply want to deploy into CICS without using CICS integration, you can package it as a JAR. Only one JAR file can be deployed into a Liberty JVM server at a time but multiple WAR files can be co-hosted.

Table 1. Spring Boot integration
Capability Spring Boot applications built into:
WAR JAR
CICS JCICS API Yes Yes
CICS link to Spring Bean Yes Yes
Java Persistance API (JPA) Yes No
Spring security integration with CICS Yes No
Spring transaction integration with CICS Yes No
Java Database Connectivity (JDBC) Yes No
Threading and concurrency Yes No
Java Message Service (JMS) Yes No

The following diagram displays the different options that you can take to run your Spring Boot application on CICS.

The different options that you can take to run your Spring Boot application on CICS.

Additional notes for building WARs

Before building, you must set the packaging type of your Spring Boot application as a deployable WAR. Your main application class must extend the SpringBootServletInitializer and override the configure method. You must also declare the Spring Boot embedded web container (typically Tomcat) as a provided dependency in your build script so that it can be replaced with Liberty's web-container at run time. In this example a main method is provided so that the application can also be built as a stand-alone JAR if required.
@SpringBootApplication
public class MyApplication extends SpringBootServletInitializer 
{
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) 
    {
        return application.sources(MyApplication.class);
    }

    public static void main(String[] args) 
    {
        SpringApplication.run(MyApplication.class, args);
    }
}

For detailed information about creating a deployable WAR file with Gradle or Maven, see Create a deployable WAR file in the Spring Boot documentation.

For more information about building applications with Maven and Gradle, see Managing Java dependencies using Maven or Gradle