Most software engineers spend their free time working on side projects. These projects are either aimed at realizing an idea or improving their skills.

Hosting these applications once the development is complete is always a good practice. This helps you to showcase your skills to potential clients.

For applications that do not have a business model, there is no need of spending money to host the apps. There are many platforms that provide free hosting services.

In this tutorial, you will learn how to host a spring boot application for free on Render using a Dockerfile. This application will be a simple REST API that returns a list of customers.


  • Knowledge of Java programming language
  • Java development kit(JDK8) and above
  • IntelliJ IDEA community edition – development environment for the Java programming language.
  • GitHub – a platform to store and manage your application.
  • Git – version control system for your application.
  • A Render Individual account – for hobbyists, students, and indie hackers. Ensure you create your account using GitHub.

Project setup

To create a new project, go to Spring initializr and select Maven in the Project section. Select Java in the Language section and 3.x.x as the version in the Spring Boot section.

The x in the version represents the latest version of Spring Boot. In the Project Metadata section, enter the respective sections as shown below.

  • Group – com.javawhizz
  • Artifact – App
  • Package name – com.javawhizz.App
  • Packaging – Jar
  • Java – 17

Press the ADD DEPENDENCIES button and add the dependencies Spring Web and Lombok. The project structure of your application should be as shown below.

app project structure
  • Spring Web – A library of the spring framework runtime for creating web applications.
  • Lombok – A library that helps you reduce boilerplate code by generating helper methods.

Press the GENERATE button to download a ZIP file containing your project. Unzip the file on your computer and import the extracted folder in IntelliJ.

Initialize GitHub repository

You must initialize the project to a Git repository since you are going to push it to GitHub.

Open a new terminal window and cd into your project. Execute the following command to initialize it to a GitHub repository.

C:\Users\redhat\Documents\Projects\App> git init

Create a customer model

In IntelliJ, create a package named customer in the package src/main/java/com/javawhizz/App.

Create a file named in the new package and copy and paste the following code into the file.

package com.javawhizz.App.customer;

import lombok.AllArgsConstructor;
import lombok.Data;

public class Customer {
    private Long customerId;

    private String firstName;

    private String lastName;

    private String email;

In this file, you have created a class named customer and you will use this class to create customers. The @Data annotation generates the getter and setter methods. The @AllArgsConstructor generates an instance of a customer having all the fields.

Create a customer controller

Create a file named in the customer package. Copy and paste the following code into the file.

package com.javawhizz.App.customer;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

public class CustomerController {
    private static final List<Customer> CUSTOMERS = List.of(
            new Customer(1L, "john", "doe", ""),
            new Customer(2L, "mary", "public", ""),
            new Customer(3L, "elon", "musk",""),
            new Customer(4L, "dunny","duncan","")

    public List<Customer> findAllCustomers(){
        return CUSTOMERS;

In this file, you have created a class for handling the HTTP requests made to your application. The @RequestMapping annotation sets the URI of the base path to api/v1/customers.

The findAllCustomers() method handles the GET requests to the application. The @GetMapping indicates that this method handles GET requests. The method returns a collection of customers defined using the List.of() method.

Package the application

A folder named target is the default folder for the Jar file. You should remove the target references in the .gitignore file.

If you do not remove the references, the target folder is not uploaded to GitHub. This means that Render will not find your Jar file during the hosting process.

Open the .gitignore file in the project root and remove the following references.


In Intellij, select View > Tool Windows > Maven to open the maven build tool for Intellij. On the panel that opens on the left side of IntelliJ, select App > Lifecycle.

To package the application, double-click on the package section under Lifecycle. The following image shows how to package the application.

This will package your application and create a Jar file named App-0.0.1-SNAPSHOT.jar.

Run and test the Jar file

Open a new terminal window and cd into the target folder of your project. To run the Jar file, execute the following command.

C:\Users\redhat\Documents\Projects\App\target> java -jar App-0.0.1-SNAPSHOT.jar

If your application starts without any errors, go to localhost:8080/api/v1/customers to test the API. The API returns a JSON response containing an Array of customers.

Create a Dockerfile

Create a file named Dockerfile in the project root. Copy and paste the following Docker commands into the file.

FROM eclipse-temurin:17-jdk-alpine
COPY target/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

These are the commands executed when hosting the application on render. The following is a description of the task performed by the Docker commands.

  • FROM – sets the base image for building the image for your application.
  • VOLUME – creates a mount point
  • COPY – copies the jar file in the target folder to a file named app.jar
  • ENTRYPOINT – sets the command to execute when starting up the application.
  • EXPOSE – sets the application to listen on port 8080 for inbound requests.

Push the project to GitHub

Go to your GitHub account and create a repository named app. Note the commands provided after creating the repository.

Open a new terminal window and follow the commands provided on your repository to push to GitHub. If your application should be as shown below. Ensure you can see the target folder.

push project to GitHub

Connect repository on Render

To connect the repository on Render, Go to the Dashboard section of Render and toggle the New button.

Since we want to deploy a dynamic application, press on Web Services section. Enter the URL of the GitHub repository in the Public Git repository section. Press the continue button to connect the repository.

connect GitHub repository

Enter application name

After connecting your repository, enter the name of the application as App, on the page that opens. Let the Region, Branch, Root Directory, and Runtime remain to default.

enter application name

Select instance type

Scroll down the page and ensure you have selected the Free instance type to avoid charges.

select instance type

Deploy the application

To deploy the application, press the Create Web Service button. This downloads the base image then builds your image and finally deploys it to the registry. Your application should be as shown below if it there were no errors during deployment.

deploy the application

The green button indicates that the application is live. The base URL of the application is on the top left side of the page below the application name.

Test the web service

Copy and paste the base URL into the search bar of your browser. To get the Array of customers, ensure you have added the path /api/v1/customers after the base path.

Here is my full URI. Your application should return the following response.


In this tutorial, you have learned how to host a Spring Boot application for free on Render.

Changes deployed to the main branch get updated in your application. This means you only deploy the application once and add features as you go using commits.

Add your custom changes and test how the application works. You can also change the application to fetch the collection of customers from a database.

The code for this project is available on GitHub. Visual learners are also not left out, the video for this tutorial is available on YouTube.

Happy Hacking!

Categories: Spring Boot


Modebe Stephen · 29 June 2023 at 11:52

After a successful build/deploy on render and after visiting your full URL you discover you are not getting any response/data, change the default port of “8080” to something else.
change ENTRYPOINT [“java”,”-jar”,”/app.jar”] to ENTRYPOINT [“java”,”-jar”,”/app.jar”, “–server.port=8083”]

Happy Hacking!

    david · 29 June 2023 at 12:19

    Hello Modebe,
    Once you make a request, give the application some time to reload.
    It will take a few seconds before the response is returned.

      jEAN · 7 September 2023 at 18:22

      When i add Spring Web dependency, i have this

      “Kotlin: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
      class org.springframework.web.filter.GenericFilterBean, unresolved supertypes: jakarta.servlet.Filter
      Adding -Xextended-compiler-checks argument might provide additional information.”

        david · 8 September 2023 at 11:22

        Hello Jean,

        It seems like the Filter class is missing.

        Try adding the Jakarta Servlet dependency.

Ehimwenman Edemakhiota · 20 July 2023 at 13:24

This is wonderful. Thank David

    david · 20 July 2023 at 13:32

    Thank you Ehimwenman.

Yamil · 27 August 2023 at 06:58

Thank you very much I was looking for a solution to deploy my app.

Nick(Nokore) · 16 October 2023 at 14:43

Thank You David, I look forward to utilizing this very soon

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *