Spring Boot Project Creation Using Command-Line Tools

Updated on Oct 05,2025

Creating a Spring Boot project doesn't always require a fancy IDE. This guide explores how to bootstrap a Spring Boot application using just command-line tools, including Spring Initializr, curl, tmux, and Vim. This approach offers a unique perspective on project setup, demystifying the underlying processes and empowering developers with a deeper understanding of the framework. Whether you're a seasoned developer looking for a new challenge or a beginner wanting to explore the command-line world, this tutorial is for you. Get ready to ditch the graphical interface and dive into the power of the command line!

Key Points

Learn to create a Spring Boot project using only command-line tools.

Understand the use of Spring Initializr's API for project generation.

Master basic Vim commands for file editing and navigation.

Utilize tmux for efficient terminal management and window multiplexing.

Explore the power of curl for making HTTP requests to the Spring Initializr API.

Discover a deeper understanding of Spring Boot project structure and dependencies.

Gain proficiency in command-line workflows for Java development.

Configure basic text editor

Setting the Stage: Prerequisites and Environment Setup

Essential Tools for Command-Line Spring Boot Development

Before diving into the creation process, it's crucial to have the right tools installed and configured. This Tutorial focuses primarily on Unix-based operating systems, but offers potential workarounds for Windows users. Here's a breakdown of the essential components:

  • Java Development Kit (JDK): A JDK is essential for compiling and running Java code. Ensure you have a compatible version installed, with Java 11 or higher recommended for modern Spring Boot projects.

    Ubuntu users can install OpenJDK 11 by using the command sudo apt install openjdk-11-jdk. Mac OS users likely already have a compatible JDK or can easily install one via Homebrew or similar package managers. Make sure that $JAVA_HOME variable are properly set.

  • Vim: Vim is a powerful, configurable text editor. Even though Vim is not user friendly, if you master it, you would find the true power of coding. This classic text editor allows for efficient file creation and modification directly from the command line. Ubuntu users can install Vim using sudo apt install vim.
  • Tmux: tmux is a terminal multiplexer, enabling you to manage multiple terminal sessions within a single window. This is invaluable for organizing your workflow and keeping everything accessible. You can install tmux using sudo apt install tmux on Ubuntu.
  • curl: curl is a command-line tool for transferring data with URLs. In this tutorial, curl will be used to interact with the Spring Initializr API. Install curl on Ubuntu using sudo apt install curl.
  • unzip: The project generated is a zip file. Unzip helps you to decompress. Install it with sudo apt install unzip.

Having these tools ready is key to a smooth command-line Spring Boot experience. While this tutorial is primarily tailored for Unix-like systems, Windows users can leverage the Windows Subsystem for Linux (WSL) to create a compatible environment.

Setting up your Vim environment is crucial for effcient development, below are some best settings to start with, if you know Vim well, you can skip this.

" Basic settings
set nocompatible  " Disable compatibility with vi
set backspace=indent,eol,start  " Enable backspace over everything

" Indentation
set tabstop=4       " Number of columns per tab
set shiftwidth=4    " Number of spaces for auto-indent
set expandtab       " Use spaces instead of tabs
set autoindent      " Automatically indent new lines
set smartindent     " More intelligent auto-indenting

" Searching
set hlsearch        " Highlight search results
set incsearch       " Show search results as you type

" UI Enhancements
syntax on           " Enable syntax highlighting
set number          " Show line numbers
set ruler           " Show cursor position

" Plugin management (example using vim-plug)
call plug#begin('~/.vim/plugged')

Plug 'tpope/vim-fugitive'  " Git integration
Plug 'scrooloose/nerdtree'  " File system explorer

call plug#end()

" NERDTree configuration
map <C-n> :NERDTreeToggle<CR>  " Toggle NERDTree with Ctrl+n

Creating a Spring Boot Project with Curl and Spring Initializr API

One awesome thing about Spring, if you are using start.spring.io to generate your project, it comes with an API endpoint.

You can leverage the Spring Initializr API to generate a basic Spring Boot project directly from the command line using curl. This offers a streamlined approach compared to navigating the Spring Initializr website.

To generate a project, craft a curl command with the desired project settings as parameters. Here's an example:

curl https://start.spring.io/starter.zip -d dependencies=web,data-jpa -d javaVersion=11 -o myproject.zip

Let's break down this command:

  • curl: Invokes the curl command-line tool.
  • https://start.spring.io/starter.zip: Specifies the Spring Initializr API endpoint for generating a zip file containing the project structure.
  • -d dependencies=web,data-jpa: Defines the project's dependencies. In this case, it includes Spring Web (for building web applications) and Spring Data JPA (for database interaction). Separate multiple dependencies with commas.
  • -d javaVersion=11: Specifies the Java version to use. Here, it's set to Java 11.
  • -o myproject.zip: Designates the output file name for the generated project as myproject.zip.

After executing this command, you'll have a zip file named myproject.zip containing the basic Spring Boot project structure with the specified dependencies and Java version. It's recommended you review its documents before starting your work.

Customizing Your Spring Boot Project Generation

The Spring Initializr API offers flexibility in customizing project generation. Here are some popular and useful parameters:

  • type: Specifies the project type (e.g., maven-project, gradle-project). Maven project and Gradle project are by far two of the most popular build systems that you can choose from.
  • groupId: Defines the project's group ID (e.g., com.example). groupId is a unique base name of the company or the group and is the same as the reverse domain name convention.
  • artifactId: Specifies the project's artifact ID (e.g., demo). ArtifactId is name the specific project.
  • name: Sets the project's name.
  • description: Provides a brief description of the project.
  • packaging: Determines the packaging type (e.g., jar, war). JAR packages multiple files into one archive file. WAR file is used to deploy web application.
  • javaVersion: Specifies the Java version (e.g., 11, 17).

By modifying these parameters in your curl command, you can fine-tune the generated project to perfectly match your requirements. When combined with Vim and Tmux, this provides a powerful environment to build great applications.

Command-Line Project Directory Structure and Setup

Now that you have a Spring Boot project, the next step is to set up the directory and prepare your editing environment. You'll need to decompress the zip file and open the project folder before doing anything else.

mkdir myproject
unzip myproject.zip -d myproject
cd myproject
  • mkdir: This command creates a new folder, the name can be whatever you choose.
  • unzip: The command decompress your zip file into the directory just created.
  • cd: Finally, switch into that directory.

With all project files unpacked, you are now ready to start building your Spring Boot project using your command-line tools!

Vim Essentials: Navigating and Editing Your Spring Boot Project

Vim might be scary at the beginning, but once you get pass the first few bumps, you will enjoy it. It is like driving a manual car, if you can only drive automatic cars, it means that you don't know how to drive. Here are some must know commands, but this is not going to be a Vim tutorial, it is only here to help you start your first project.

  • Normal Mode Commands: These commands are used for navigation and file manipulation.
    • i: Insert mode (enter text input).
    • :w: Save the current file.
    • :q: Quit Vim.
    • :wq: Save the file and quit.
    • :q!: Quit Vim without saving changes.
    • gg: Go to the beginning of the file. (Capitalized GG)
    • Shift + g: Go to the end of the file. (Shift key combined with g)
    • $: Move the cursor to the end of the current line.
    • 0: Move the cursor to the beginning of the current line.
    • dd: delete the current line.
  • Search Commands: Quickly locate text within the file.
    • /pattern: Search forward for the specified pattern.
    • ?pattern: Search backward for the specified pattern.
    • n: Move to the next match.
    • N: Move to the previous match.
  • Netrw Directory Listing.
    • :edit: It let you open up directory structure. With these fundamental Vim commands, you can efficiently navigate and edit your Spring Boot project files.

Testing the Application: Command-Line Curl Requests

Once you have set up your Spring Boot app, we need to call it from the terminal.

You can do this with a http client like curl with simple commands

curl -X POST -H "Content-Type: application/json" -d '{"name": "Test Ale", "abv": 6.5}' http://localhost:8080/beers

This command creates a beer using POST and Content-Type. You need to be aware that, by convention, your restful resource will be plural, for example your class entity is Beer, then you need to call the beers restful endpoint.

When you run the project, you should see something like below that confirm the service is running successfully

{
  "name": "Test Ale",
  "abv": 6.5,
  "id": 2,
  "_links": {
    "self": {
      "href": "http://localhost:8080/beers/2"
    },
    "beer": {
      "href": "http://localhost:8080/beers/2"
    }
  }
}

Enhancing Productivity with Tmux

Tmux Workflow: Multiple Windows

Managing multiple files and processes in a single terminal window can quickly become overwhelming. Tmux comes to the rescue, providing a way to create multiple panes and windows within a single terminal session, this becomes extremely useful with command-line.

Basic Tmux Commands

  • Ctrl+b %: Split the current pane vertically.
  • Ctrl+b ": Split the current pane horizontally.
  • Ctrl+b <arrow key>: Move between panes using the arrow keys.
  • Ctrl+b c: Create a new window.
  • Ctrl+b <number>: Switch to the window with the specified number.

With these tmux commands, you can arrange your development environment for peak efficiency. For example, you can divide windows for code-editing, for compilation, or to run the server.

Streamlining Development with Command-Line Tools

Command-Line Workflow for Spring Boot Applications

Leveraging command-line tools effectively can transform your development workflow. Here's a suggested approach:

  1. Project Setup: Begin by creating the basic project using the command in the video. This provides a standardized initial configuration.
  2. Editing: Add the properties with Vim. Edit your code as normal, don't forget to save the file after the edit is done.
  3. Build and Run: Use mvnw spring-boot:run or gradle bootRun to compile and execute your Spring Boot project. Monitor the output in its own tmux window to catch errors in no time.
  4. Testing: Use curl to do GET, PUT, DELETE requests against your api.
  5. Commit: Use your favorite command line tool to commit code. Push or pull in remote server.

By mastering these commands you would drastically increase the development speed. You are one step closer to become a true backend ninja.

The Cost of Command-Line Development

Open Source Tools: A Cost-Effective Approach

One of the most significant advantages of command-line development is its reliance on open-source tools. Vim, tmux, curl, and the Spring Initializr API are all freely available, eliminating the need for costly IDE licenses. This makes it an attractive option for individual developers, startups, and organizations looking to minimize their software expenses.

The cost of building Spring boot applications can vary depending on your infrastructure. But the tools mentioned in this guide are free.

The Bottom Line: Pros and Cons of Command-Line Development

👍 Pros

Increased control and customization capabilities

Automation potential through scripting

Lightweight and resource-efficient

Command-line familiarity is an advantage on server environments

Deepen your understanding of the stack.

👎 Cons

Steep learning curve for beginners

Requires familiarity with command-line tools

Potentially less efficient for managing complex projects

Limited graphical interface and debugging capabilities

Key Features of Command-Line Development Stack

Power, Flexibility, and Control

The command-line development approach offers a unique set of features that cater to different needs and preferences:

  • Fine-Grained Control: The command line allows meticulous configuration of every project aspect, free from the abstractions of IDEs.
  • Automation and Scripting: Command-line tools excel at automation. You can create scripts to streamline repetitive tasks such as project creation, build processes, and deployment.
  • Remote Server Compatibility: Many server environments are primarily command-line based. Mastering these tools makes you better equipped to manage and troubleshoot applications in real-world production environments.
  • Resource Efficiency: Command-line tools are generally lighter and more resource-efficient than resource-intensive IDEs. This can be particularly beneficial when working on older hardware or resource-constrained environments.

Where Command-Line Development Shines

Ideal Scenarios for Command-Line Development

Although command-line development may not be for everyone, there are situations where it shines. It is like a master artisan uses traditional tools to create masterpiece, even though he can utilize more advanced machines.

  • Server-Side Development: Managing and deploying applications on remote servers often requires command-line proficiency.
  • Automation and DevOps: Creating scripts and automating build processes is central to DevOps practices, and the command line is the ideal tool for these tasks.
  • Educational Purposes: Understanding the underlying mechanisms of project creation and build processes can enhance your development skills. Command-line development offers a unique perspective.
  • Resource-Constrained Environments: Working on older machines or systems with limited resources can benefit from the lighter footprint of command-line tools.

Frequently Asked Questions About Command-Line Spring Boot Development

Is command-line development suitable for beginners?
While it can be challenging initially, it's a rewarding learning experience. It forces you to understand the underlying processes and configurations. The best way is to start from a basic project.
Is this approach Windows-compatible?
Primarily suited for Unix-like systems, but can be used through setting up the Windows Subsystem for Linux (WSL). You can follow the steps to setup from the guide and then apply to the current guide.
Can I use this approach for large and complex Spring Boot projects?
While possible, it might become cumbersome for very large projects with numerous dependencies. IDEs excel at managing complexity, but for many moderate sized projects, this approach is feasible.
Can I use other Java text editors instead of Vim?
There are many other java friendly text editors that you can try.

Exploring Further: Related Questions and Resources

Where can I find more information about the Spring Initializr API?
Check out the official Spring Initializr documentation. You can also explore related technologies, such as REST APIs, command-line automation and software development

Most people like