Skip to content

just run

$ just run

What does it do?

just run runs the Spring Boot application in the development mode with live reload and zero config infrastructure services.

Live Reload

To run application in the development mode with live reload, just executes following steps:

Maven

Info

For the best results it is recommended to have Maven Daemon installed in your system.

1️⃣ Detects the best command to run Maven goals and plugins in following order:

  • mvnd - uses Maven Daemon if is installed
  • ./mvnw - uses Maven Wrapper if wrapper files are generated
  • mvn - uses regular Maven command

2️⃣ Decorates pom.xml with following dependencies:

  • org.springframework.boot:spring-boot-devtools - there is no need to add devtools to pom.xml when using Just
  • com.maciejwalkowiak.just-spring-boot - thin zero-dependencies just client to communicate with Just server

Decorated pom.xml is saved as .pom.xml.tmp and gets deleted when just run command is stopped.

3️⃣ It starts Spring Boot application using spring-boot:run

4️⃣ It watches src directory for changes.

  • if any file in src/main/java changed, it runs compiler:compile Maven plugin
  • if any file in src/main/resources changed, it runs resources:process-resources Maven plugin
  • if pom.xml file changed, stops the spring-boot:run goal and starts it again with new refreshed pom.xml

Gradle

1️⃣ Detects the best command to run Gradle goals and plugins in following order:

  • ./gradlew - uses Gradle Wrapper if wrapper files are generated
  • .gradle - uses regular Gradle command

2️⃣ Adds following dependencies to Gradle:

  • org.springframework.boot:spring-boot-devtools - there is no need to add devtools to pom.xml when using Just
  • com.maciejwalkowiak.just-spring-boot - thin zero-dependencies just client to communicate with Just server

3️⃣ It starts Spring Boot application using bootRun plugin.

4️⃣ It runs Gradle continuous process that fires build when source files change.

Disabling Live Reload

Live Reload can be disabled through setting a property in just.properties:

just.run.live-reload.enabled=false

When Live Reload is disabled, just run starts Spring Boot Devtools runner but does not react to changes in source files. It does restart runner whenever a change in build files happen.

Frontend Resources Live reload

Just enables live reloading of frontend resources without a need to refresh the browser manually. This feature is based on Spring Boot LiveReload integration, but saves you from installing the browser extension.

Whenever a Thymeleaf template or a static resource like CSS or JavaScript file changes, Just triggers the Maven or Gradle to process it and notifies the browser about changes.

Frontend Resources Live reload can be disabled by setting a property in just.properties:

just.run.live-reload.browser.enabled=false

Zero Config Infrastructure Services

just-spring-boot dependency that gets added transparently to the project when running just run, 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 start PostgreSQL database and set all spring.datasource.* properties needed by the application to connect to Postgres.

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

Docker Compose support

If project contains docker-compose.yml, just run will automatically start services defined in Docker Compose. Whenever a change in docker-compose.yml happens, just invokes docker compose up --remove-orphans to refresh running containers.

When Docker Compose support is enabled and docker-compose.yml file exists, the zero-config infrastructure services feature gets automatically disabled.

Warning

To run containers with Docker Compose with just, you must have Docker Compose installed in version 2.7.0 or newer.

Docker Compose support can be disabled through setting a property in just.properties:

just.run.docker-compose.enabled=false

Docker Compose file can be customized with property:

just.run.docker-compose.file=services.yml

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

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

Running multi-module Maven projects

Starting from version 0.13.0, Just works with multi-module Maven projects.

$ just run <module-directory>

For example for following project structure:

.
├── application
│   └── pom.xml
├── library
│   └── pom.xml
└── pom.xml

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