Java Monolithic with Spring Boot and PostgreSQL
This project is an implementation of a monolithic architecture using Spring Boot with Java 17, and PostgreSQL as the database.
Additionally, the project includes a full CRUD, field validation, exception handling, and automatic documentation using Swagger.
📚 Table of Contents
✅ Features
- Full CRUD generation for client management.
- Monolithic Architecture using Spring Boot.
- Dynamic connection to PostgreSQL.
- Data validation with Spring annotations (
@NotNull
, @Size
, etc.).
- Global exception handling with custom responses.
- Swagger for automatic API documentation.
- Generic responses with the format
{status: true/false, data: <response>, message: <message>}
.
- Modular and scalable code ready for production.
⚙️ Requirements
- Java 17
- Accessible PostgreSQL
- Maven for dependency management
- Visual Studio Code (or any IDE of your choice)
📦 Installation
Clone or download the repository.
At the root of the project, install the dependencies using Maven:
mvn install
Run the project with:
mvn spring-boot:run
⚙️ Configuration
application.properties file
Configure the database parameters in the file src/main/resources/application.properties:
properties
spring.datasource.url=jdbc:postgresql://localhost:5432/mi_base_de_datos
spring.datasource.username=usuario
spring.datasource.password=contraseña
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
bash
Swagger UI Link
You can access the Swagger UI interface at the following URL:
Swagger UI
🧱 Project Structure
The basic structure of the project is as follows:
Description of Directories and Files:
logs/
: Folder where system logs are stored.
pom.xml
: Maven configuration file for managing the project dependencies.
src/
: Contains the source code of the project.
main/
: Production source code.
java/
: Java source code.
com/lurawi/monolitico/
: Root package of the project.
controller/
: Controllers that handle HTTP requests.
RegistroController.java
: Controller for managing client registration.
domain/
: Contains the domain model.
model/
: Data model classes.
Cliente.java
: Representation of a client.
repository/
: Repositories for interacting with the database.
ClienteRepository.java
: Repository for the Cliente
entity.
service/
: Business logic.
ClienteService.java
: Service that handles the logic for clients.
support/
: Helper classes.
dto/
: Data Transfer Objects.
ClienteResponse.java
: DTO response for the client.
exception/
: Exception handling.
ApiException.java
: Exceptions related to the API.
GlobalExceptionHandler.java
: Global exception handler.
resources/
: Configuration files and static resources.
logback.xml
: Logging configuration.
application.properties
: Application configuration.
static/
and templates/
: Static resources and templates.
test/
: Test code.
java/
: Test files in Java.
com/lurawi/monolitico/
: Test package.
controller/
: Controller tests.
RegistroControllerTest.java
: Tests for the RegistroController
controller.
service/
: Service tests.
RegistroServiceTest.java
: Tests for the RegistroService
service.
Just create the file and run the plugins, and you're done.
# .env
DB_USER=postgres
DB_HOST=localhost
DB_DATABASE=lurawi
DB_PASSWORD=admin
DB_PORT=5432
📄 License
This project is under the ISC license. See the LICENSE
file for more details.
Do you have questions or suggestions? Contact me!
Thanks for using this extension to speed up your development with Java Monolithic with Spring Boot and PostgreSQL! 🙌