Skip to content

This is a Spring Boot project template that includes commonly used dependencies for building a RESTful web application. The project is pre-configured with Spring Web, Spring Data JPA, Lombok, Spring Boot DevTools, and an H2 in-memory database.

Notifications You must be signed in to change notification settings

felippeneves/spring-boot-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-boot-api

Description

This is a Spring Boot project template that includes commonly used dependencies for building a RESTful web application. The project is pre-configured with Spring Web, Spring Data JPA, Lombok, Spring Boot DevTools, and an H2 in-memory database.

Features

  • Spring Web: Enables the development of RESTful APIs.
  • Spring Data JPA: Simplifies database interactions with JPA and Hibernate.
  • Lombok: Reduces boilerplate code by generating getters, setters, constructors, and more.
  • Spring Boot DevTools: Provides hot reloading and enhances the development experience.
  • H2 Database: In-memory database for rapid prototyping and testing.

Prerequisites

  • Java 17 or later
  • Maven 3.6+ or Gradle
  • IDE (IntelliJ IDEA, Eclipse, VS Code, etc.)

Getting Started

Clone the Repository

git clone https://github.com/felippeneves/spring-boot-api.git
cd your-repository

Build and Run

Using Maven:

./mvnw spring-boot:run

Using Gradle:

./gradlew bootRun

Application Endpoints

By default, the application runs on http://localhost:8080. You can test available endpoints using tools like Postman or cURL.

Configuration

Database Configuration

The project uses an H2 in-memory database. The default configuration is defined in application.properties:

spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true

Access the H2 database console at: http://localhost:8080/h2-console (Use jdbc:h2:mem:testdb as the JDBC URL)

Lombok Setup

Ensure your IDE has Lombok enabled:

  • IntelliJ IDEA: Enable annotation processing in Settings > Build, Execution, Deployment > Compiler > Annotation Processors.
  • Eclipse: Install Lombok plugin and restart the IDE.

Project Structure

/src/main/java/com/felippeneves/spring_boot_api
    ├── controllers         # REST controllers
    ├── domain
    │   ├── exceptions     # Custom exception handling
    │   ├── transaction    # Transaction-related entities
    │   ├── user           # User-related entities
    ├── dtos               # Data Transfer Objects (DTOs)
    ├── infra              # Infrastructure configurations
    ├── repositories       # JPA repositories
    ├── services           # Business logic layer
    ├── SpringBootApiApplication # Main application entry point
/src/main/resources
    ├── static
    ├── templates
    ├── application.properties  # Configuration file

Dependencies

The project uses the following dependencies:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Author

Felippe Neves

About

This is a Spring Boot project template that includes commonly used dependencies for building a RESTful web application. The project is pre-configured with Spring Web, Spring Data JPA, Lombok, Spring Boot DevTools, and an H2 in-memory database.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages