This repository serves as an advanced Spring Boot starter pack, designed to streamline development with pre-configured integrations for database connections, Spring Security with JWT (including refresh token mechanism), email services, and Aspect-Oriented Programming (AOP) for logging. Developers can quickly adapt this project with minimal configuration adjustments to meet their needs.
- Java 17 & Gradle (recommended version: 8.10.2).
- PostgreSQL or SQL Server installed for database support.
- Gmail account for email integration.
-
Clone the Repository
git clone https://github.com/Aligorithm-97/SpringBootAdvancedStarterPack.git cd SpringBootAdvancedStarterPack
-
Install Java 17 and Gradle
- Ensure Java 17 is installed on your system.
- Install Gradle (recommended version: 8.10.2) if not already installed.
-
Database Setup
- SQL Server:
- Update
application-dev.properties
with your SQL Server details:spring.datasource.url=jdbc:sqlserver://<your-sql-server-url>:<port>;databaseName=<database> spring.datasource.username=<your-username> spring.datasource.password=<your-password>
- Update
- PostgreSQL:
- Install PostgreSQL if it is not already installed.
- Use pgAdmin to create a new database.
- Update
application-dev.properties
with your PostgreSQL details:spring.datasource.url=jdbc:postgresql://<host>:<port>/<database> spring.datasource.username=<your-username> spring.datasource.password=<your-password>
- SQL Server:
-
Email Integration
- Generate an app-specific password in your Gmail account.
- Update
application-dev.properties
with your Gmail credentials:spring.mail.mailUsername=<your-email> spring.mail.mailPassword=<app-password>
-
CORS Configuration
- By default, the CORS configuration allows all ports for development purposes.
- Update the allowed origins in
BeansConfig
for production as needed:configuration.setAllowedOrigins(Arrays.asList(<your-domain-or-ip>));
-
Activate User Accounts
- Add the URL of your UI for account activation in
application-dev.properties
:application.mailing.frontend.activation-url=http://<your-ui-url>/activate
- Add the URL of your UI for account activation in
-
Troubleshooting
- If all the above steps have been completed and you still encounter errors, it could be due to the Lombok annotation processor not functioning correctly.
- To resolve this:
- Ensure Lombok is installed and enabled in your IDE.
- For IntelliJ IDEA:
- Go to File > Settings > Plugins, search for
Lombok
, and install it if it’s not already installed. - Enable annotation processing:
File > Settings > Build, Execution, Deployment > Compiler > Annotation Processors, and check Enable annotation processing.
- Go to File > Settings > Plugins, search for
-
Database Integration
- PostgreSQL: Pre-configured in
application-dev.properties
. Simply install PostgreSQL, create the database using pgAdmin, and update properties such asport
,database name
, andcredentials
as needed. - SQL Server: Configuration is available for SQL Server. Update the necessary details and include the required dependencies in
build.gradle
to switch to SQL Server.
- PostgreSQL: Pre-configured in
-
Spring Security with JWT
- Includes JSON Web Token (JWT) authentication for securing APIs.
- Supports Refresh Token Mechanism:
- Enables seamless token renewal without requiring users to re-authenticate.
- Designed for use with front-end interceptors to manage token refresh automatically.
- Pre-configured endpoints for obtaining access and refresh tokens.
- CORS Configuration:
- Development: Allow origins like
localhost
and specific ports. - Production: Set allowed origins to your domain or IP in the
BeansConfig
class.
- Development: Allow origins like
-
Email Integration
- Pre-configured for email sending using Gmail.
- Setup Instructions:
- Generate an app-specific password in your Gmail account.
- Update
application-dev.properties
with your Gmail username and app password.
-
Aspect-Oriented Programming (AOP)
- Includes logging functionality for cross-cutting concerns.
-
Global Exception Handling
- Pre-configured global exception handler for managing API errors consistently.
-
Environment Support
- Built with Java 17.
- Uses Gradle for dependency management and build.
Thank you for using this advanced starter pack. If you have any feedback or suggestions, feel free to contribute to the repository. Wishing you success in your development journey. Happy coding! 🚀