This guide will help you set up and run the Spring Boot Boilerplate application locally.
Before you start, ensure you have the following installed on your machine:
- Java Development Kit (JDK): Ensure you have JDK 21 (or the required version installed for your setup).
- Download JDK
- Verify installation:
java -version
- Gradle: (Optional) The project includes the Gradle Wrapper, so you don't need a system-wide Gradle installation.
- Download Gradle
- Verify installation:
gradle -v
Clone the repository using the following command:
git clone https://github.com/Prem-Dharshan/springboot_boilerplate.gitNavigate to the project directory:
cd springboot_boilerplateAlternatively, fork the repository and clone it from your fork.
Open the build.gradle file and ensure the Java version matches the version installed on your machine. Modify the java.toolchain block as follows:
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21) // Replace 21 with your desired Java version
}
}Save the file after making the changes.
If your Gradle version is outdated, update it in the gradle-wrapper.properties file:
- Open the file located at
gradle/wrapper/gradle-wrapper.properties. - Update the
distributionUrlto the desired Gradle version. For example:distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
You can check the Gradle Releases Page to find the latest version.
Run the Gradle build command to compile the application:
./gradlew buildOn Unix-based systems, if you encounter permission issues, use:
chmod +x gradlew ./gradlew build
Start the application with the following command:
./gradlew bootRunOnce the application starts, it will be accessible at:
-
Build Fails:
- Ensure the correct Java version is installed and matches the
build.gradleconfiguration. - Clean the project if you encounter issues:
./gradlew clean
- Ensure the correct Java version is installed and matches the
-
Port Already in Use:
- Stop the existing process running on port 8080 or modify the
server.portproperty insrc/main/resources/application.properties:server.port=8081
- Stop the existing process running on port 8080 or modify the
-
Gradle Version Compatibility:
- If you encounter issues due to an outdated Gradle version, ensure the
distributionUrlingradle-wrapper.propertiespoints to a compatible version of Gradle for your Java version.
- If you encounter issues due to an outdated Gradle version, ensure the
If you make improvements or fixes, consider contributing by opening a pull request to the original repository.
-
To run tests:
./gradlew test -
To clean the project:
./gradlew clean
-
To generate a JAR file:
./gradlew bootJar
Enjoy coding with the Spring Boot Boilerplate! 🚀