To run a Spring Boot application using Gradle, follow these steps:
-
Open a terminal or command prompt.
-
Navigate to the root directory of your Spring Boot project.
-
(Optional) Compile the project: It's generally not necessary to compile separately as the run command will do this, but if you want to ensure everything compiles correctly first:
gradle compile
Or using the wrapper:
./gradlew compile
-
Run the application using one of the following commands:
a) Using the Gradle wrapper (recommended):
- On Unix-based systems (Linux, macOS):
./gradlew bootRun - On Windows:
gradlew.bat bootRun
b) If Gradle is installed globally on your system:
gradle bootRun - On Unix-based systems (Linux, macOS):
-
Gradle will compile your project (if not done already), download necessary dependencies, and run the Spring Boot application.
-
Wait for the application to start. You'll see logs in the console indicating that the application is running.
docker-compose up --buildAdd the -d flag to run containers in detached mode:
docker-compose up --build -dCheck the Status of Containers
Use the following command to check the status of running containers:
docker-compose psAccess the Application
temporally: Once the containers are running, you can access the application through
the exposed ports specified in docker-compose.yml.
For example, gateway is exposed on port 8080, you can access it at http://localhost:8080.
Stop and Remove Containers
To stop and remove all containers, networks, and volumes defined in docker-compose.yml, run:
docker-compose downTo also remove built images, add the --rmi all option:
docker-compose down --rmi all