JUST – CLI for developing Spring Boot applications
JUST is command line toolkit which greatly simplifies the developing of Spring Boot Applications.
Introducing Just, the go-to command line tool designed to enhance your Spring Boot developer experience! Currently offering the incredible “Just Run” feature.
Get ready for Just Run, the only command you’ll need to kickstart your Spring Boot application in development mode. It seamlessly takes care of:
1. Live reload – Say goodbye to the hassle of rebuilding, recompiling, or restarting applications. Just save your changes in IntelliJ IDEA and watch as Just compiles the updated code, reflecting alterations in mere seconds.
2. Zero-config infrastructure services – Starting infrastructure services like databases and message queues has never been easier. Just detects your application’s connection to a service, launches a docker container, and configures the connection effortlessly. Plus, these services launch only once without impacting live reload performance!
3. Docker compose integration – Utilizing a docker-compose.yml for local development? Just will automatically execute “docker compose up” before launching your application and even live reloads Docker containers whenever the docker-compose.yml file is modified.
4. Project run command selection – Maven or Gradle? Daemon or Wrapper? With Just Run, there’s no need to choose. Everything is determined automatically for you.
Requirements
Spring Boot projects that require Java 11+ and compatible with Spring Boot Dev tools
Docker if you want to use zero-config infrastructure services or docker compose file
Installation
JUST can be installed either using package managers (Homebrew for Mac OS, scoop for Windows) or manually by downloading the binary.
Note: At the moment only x86_64 architectures are supported.
Using Scoop
scoop bucket add maciejwalkowiak https://github.com/maciejwalkowiak/scoop-just.git
Code language: Java (java)
scoop install just
Code language: Java (java)
Manual
Download just-0.12.0-windows-x86_64.zip, unzip it, and place just.exe
in the PATH
.
Using Homebrew
brew install maciejwalkowiak/brew/just
Code language: Java (java)
Manual
curl -Lo just.zip https://github.com/maciejwalkowiak/just/releases/latest/download/just-0.13.0-osx-x86_64.zip && unzip just.zip && chmod +x just && sudo mv just /usr/local/bin/just && just help
Code language: Java (java)
Manual
curl -Lo just.zip https://github.com/maciejwalkowiak/just/releases/latest/download/just-0.13.0-linux-x86_64.zip && unzip just.zip && chmod +x just && sudo mv just /usr/local/bin/just && just help
Code language: Java (java)
You can test the installation with following command.
just help
Code language: Java (java)
?????? ????????????????????
?????? ????????????????????
?????? ??????????? ???
?? ?????? ??????????? ???
????????????????????????? ???
?????? ??????? ???????? ???
Usage: just [-V] [COMMAND]
-V, --version Print Just version
Commands:
run runs Spring Boot project - either with Maven or Gradle in dev mode
with hot reloading enabled
help Display help information about the specified command.
format formats code with Spotless
init initializes Just related files
build builds application
kill kills process running on port
Code language: Java (java)
How it works?
JUST CLI transparently adds Spring Boot Devtools dependency to the project and also monitors the source for changes and starts compilation using Maven or Gradle when it detects a change.
It also responds to changes in build files such as pom.xml or build.gradle; anytime a change occurs, it pauses the Spring Boot application, refreshes the build file, and restarts the application. Because of this, you may execute run only once, amend any source file, and the programme will take care of reflecting the changes.
JUST CLI also starts the its own server on random available port
Usage
Now let’s look at the how to use Just CLI.
You have to run following commands from the root of the project.
Just run
just run
Code language: Java (java)
The above command launches Spring Boot application in the development mode with live reload, Docker Compose Support and zero config infrastructure services.
Passing command line arguments to Maven/Gradle
Anything that is added after just run
is passed to Maven/Gradle commands. For example, to activate a Maven profile named local
run:
$ just run -Plocal
Code language: Java (java)
Running just server on fixed port
By default just run
starts the just
server on the random available port. To run it with fixed port, set the environment variable JUST_SERVER_PORT
:
$ JUST_SERVER_PORT=8081 just run
Code language: Java (java)
Running multi-module Maven projects
Just ( from versio 0.13) works with multi-module Maven projects.
$ just run <module-directory>
Code language: Java (java)
For example for following project structure:
.
├── application
│ └── pom.xml
├── library
│ └── pom.xml
└── pom.xml
Code language: Java (java)
application
module is the one that is meant to be run (it has @SpringBootApplication
annotated class), to run project with just execute:
$ just run application
Code language: Java (java)
Just build
just build
Code language: Java (java)
just build command builds the spring boot project. The command automatically detects Maven or Gradle build tool and picks up the best command to execute ( mvn
, ./mvnw
, mvnd
, gradle
, ./gradlew
)
Command | Description | Maven | Gradle |
just build | builds the jar | mvn package | gradle build |
just build native | mvn native:compile -Pnative | gradle nativeCompile | |
just build native-image | builds a Docker Image with a native executable | mvn spring-boot:build-image -Pnative | gradle bootBuildImage |
just build image | builds a Docker Image with an executable JAR | mvn spring-boot:build-image | gradle bootBuildImage |
just build command can be customized by using just.properties or just.yml file in project root directory.
Property | Description | Default value |
---|---|---|
just.build.extra-args | Extra command line arguments passed to Maven or Gradle | |
just.build.default-target | a default target to build when the command is invoked with just build | jar |
just.build.services.enabled | enables/disables Zero-Config Infrastructure Services feature during the build phase | true |
just format
just format
Code language: Java (java)
just format
formats the code with Spring Java Format or Spotless depending on the plugin configured.
If none of the plugin is configured , it defaults to Spring Java Format.
just kill
$ just kill -p 8082
Code language: Java (java)
just kill
allows you to quickly and easily kill processes that are listening on specific ports. This can be useful if you need to free up a port for a different process, or if you want to stop a process that is no longer needed.
Customizing Just
just run command can be customized by using just.properties or just.yml file in project root directory.
Property | Default value | Description |
just.framework | none | This should be used only if Just is unable to identify that the project utilises Spring Boot for some reason. SPRING_BOOT is one of the possible values. |
just.run.live-reload.enabled | true | enables/disables live-reload feature |
just.run.live-reload.browser.enabled | true | enables/disables frontend resources reload without a browser refresh |
just.run.maven.profiles | a comma-separated list of Maven profiles to activate (passed with -Pprofile1,profile2 ) | |
just.run.spring-boot.profiles | a comma-separated list of Spring Boot profiles to activate (as spring.profiles.active ) | |
just.run.docker-compose.enabled | true | enables/disables Docker Compose feature |
just.run.docker-compose.file | docker-compose.yml | Docker Compose YML file path relative to project root |
just.run.services.enabled | true | enables/disables Zero-Config Infrastructure Services feature |
Docker Compose support
If your project uses docker compose file to start the database, queue service or any other service, JUST CLI can start the services defined in the docker compose file.
To refresh running containers, just execute docker compose up –remove-orphans whenever there is a change in docker-compose.yml
The zero-config infrastructure services capability is immediately disabled when Docker Compose support is enabled and a docker-compose.yml file exists.
Docker Compose support can be disabled through setting a property in just.properties
:
just.run.docker-compose.enabled=false
Code language: Java (java)
Docker Compose file name and path can be customized with property:
just.run.docker-compose.file=services.yml
Code language: Java (java)
Note
Zero Config Infrastructure Services
just run command, communicates with Just server to start infrastructure services whenever a configuration property for such service is not set.
For example, if you add spring-boot-starter-data-jpa
and a JDBC driver for PostgreSQL but you do not set spring.datasource.url
property in application.properties
, Just will automatically download docker image of Postgres Database and start database and set all spring.datasource.*
properties needed by the application to connect to Postgres.
To start zero config services JUST CLI internally makes use of Tesstcontainers libraries.
This applies to following infrastructure services:
- PostgreSQL
- MySQL
- MongoDB
- Neo4j
- RabbitMQ
Infrastructure Services can be disabled through setting a property in just.properties
:
just.run.services.enabled=false
Code language: Java (java)
If are using zero config infrastructure , you can customize the properties like image and port to be used and enable/disable services.
PostgreSQL
Property | Description | Default value |
---|---|---|
just.run.services.postgres.enabled | enables/disables starting PostgreSQL database when requested | true |
just.run.services.postgres.log-queries | enables/disables logging SQL queries by PostgreSQL (experimental) | false |
just.run.services.postgres.image-name | PostgreSQL Docker Image Name | postgres:13.3 |
just.run.services.postgres.port | TCP port on which PostgreSQL is exposed | 5432 |
MySQL
Property | Description | Default value |
---|---|---|
just.run.services.mysql.enabled | enables/disables starting MySQL database when requested | true |
just.run.services.mysql.image-name | MySQL Docker Image Name | mysql:8.0.30 |
just.run.services.mysql.port | TCP port on which MySQL is exposed | 3306 |
RabbitMQ
Property | Description | Default value |
---|---|---|
just.run.services.rabbitmq.enabled | enables/disables starting RabbitMQ when requested | true |
just.run.services.rabbitmq.image-name | RabbitMQ Docker Image Name | rabbitmq:3.7.25-management-alpine |
just.run.services.rabbitmq.port | TCP port on which RabbitMQ is exposed | 5672 |
just.run.services.rabbitmq.management-port | TCP port on which RabbitMQ Management Console is exposed | 15672 |
Neo4j
Property | Description | Default value |
---|---|---|
just.run.services.neo4j.enabled | enables/disables starting Neo4j database when requested | true |
just.run.services.neo4j.image-name | Neo4j Docker Image Name | neo4j:4.4 |
just.run.services.neo4j.port | TCP port on which Neo4j is exposed | 7687 |
MongoDB
Property | Description | Default value |
---|---|---|
just.run.services.mongodb.enabled | enables/disables starting MongoDB database when requested | true |
just.run.services.mongodb.image-name | MongoDB Docker Image Name | mongo:4.0.10 |
just.run.services.mongodb.port | TCP port on which MongoDB is exposed | 27017 |
Redis
Property | Description | Default value |
---|---|---|
just.run.services.redis.enabled | enables/disables starting Redis database when requested | true |
just.run.services.redis.image-name | Redis Docker Image Name | redis:7.0.5-alpine |
just.run.services.redis.port | TCP port on which Redis is exposed | 6379 |
Zipkin
Property | Description | Default value |
---|---|---|
just.run.services.zipkin.enabled | enables/disables starting Zipkin when requested | true |
just.run.services.zipkin.image-name | Zipkin Docker Image Name | openzipkin/zipkin:2.24 |
just.run.services.zipkin.port | TCP port on which Redis is exposed | 9411 |