This file can be used as a template for initializing and running spring projects.
What's included:
- Gradle file created from start.spring.io
- Plugins for Spotbugs, Checkstyle and Jacoco included (Disabled : to enable add
id 'checkstyle'
to build.gradle) - Other dependencies like Mongo, MySql and redis.
- Dockerfile to start mongo server and run the spring boot application within.
Usage -
- To build the repository -
From the repository root,
- run
./gradlew build test
run the build - run
./gradlew bootjar
to create executable jar. The jar will be located inside build directories. - run
./gradlew bootrun
to directly start the spring boot application accessible on (https://localhost:8081/say-hello?messageId=001
)
To run inside docker container, use below commands
To build docker image, use the command below - docker build -t your_tag_name .
To run the generated container, use this command - docker run -p8080:8080 your_tag_name
. This will run the server on 8080 port.. You can change the ports as per your needs.
Follow below steps to use this repository as a starter stub for a new spring-boot project
- Create a new repository
demo-project
- set up a new project locally on your workspace
mkdir demo-project && cd demo-project
echo " " >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin <repo-url-demo-project>
git push -u origin main
- Downloading
Spring-Starter
as a stub for your current project git remote add starter-stub https://github.com/sambit77/Spring-Starter.git
git config pull.rebase false
git pull starter-stub main --allow-unrelated-histories --no-edit
- Manually resolve merge conflict on README.md file from UI
git add .
git commit -m "starter stub added"
git push -u origin main
Ensure a working codebase:-
- Depedencises : Mongodb , java jdk
- Verify mongo connectivity by pushing sample data to mongodb
./start.sh
- Run Spring Application
chmod +x ./gradlew
and then./gradlew bootrun
- Check working of rest api from another terminal
curl "https://localhost:8081/say-hello?messageId=001"
, Sample Output{"message":"Hello world"}
- Test for working testcases
./gradlew test