Skip to main content

Prerequisites

Before you begin, ensure you have the following installed on your system:

Java 17

The project requires Java 17 or higher

Maven

Apache Maven for dependency management and building

PostgreSQL

PostgreSQL database server (version 12 or higher)

Git

Git for cloning the repository

Verify Java Installation

java -version
You should see output indicating Java 17 or higher:
openjdk version "17.0.x"

Verify Maven Installation

mvn -version

Clone the Repository

1

Clone the repository

Clone the Library API repository to your local machine:
git clone <repository-url>
cd libraryapi
2

Verify project structure

Ensure the project structure is correct:
ls -la
You should see:
  • pom.xml - Maven configuration file
  • src/ - Source code directory
  • mvnw and mvnw.cmd - Maven wrapper scripts

Build the Project

1

Install dependencies

Use Maven to download all required dependencies:
mvn clean install
The first build may take several minutes as Maven downloads all dependencies.
2

Compile the application

Compile the source code:
mvn compile
3

Run tests (optional)

Verify everything is working by running tests:
mvn test

Configure the Database

Before running the application, you need to configure the PostgreSQL database connection.
Make sure PostgreSQL is running and you have created a database named library. See the Database Configuration guide for detailed instructions.
Edit src/main/resources/application.properties:
spring.application.name=libraryapi
spring.datasource.url=jdbc:postgresql://localhost:5432/library
spring.datasource.username=postgres
spring.datasource.password=your_password
spring.datasource.driver-class-name=org.postgresql.Driver

spring.jpa.hibernate.ddl-auto=update

Run the Application

Run the application using the Spring Boot Maven plugin:
mvn spring-boot:run

Verify Installation

Once the application starts, you should see output indicating the server is running:
Started LibraryapiApplication in X.XXX seconds
1

Check application health

The application runs on port 8080 by default. Verify it’s running:
curl http://localhost:8080/
2

Test authentication

Try accessing a protected endpoint to verify security is working:
curl http://localhost:8080/api/books
You should receive a 401 Unauthorized response, indicating security is properly configured.

Common Issues

If port 8080 is already in use, you can change it by adding this to application.properties:
server.port=8081
Ensure:
  • PostgreSQL is running
  • The database library exists
  • Username and password are correct
  • PostgreSQL is accepting connections on port 5432
See the Database Configuration guide for more details.
Try clearing the Maven cache and rebuilding:
mvn clean
rm -rf ~/.m2/repository
mvn install
The project requires Java 17. If you have multiple Java versions installed, set JAVA_HOME:
export JAVA_HOME=/path/to/java17

Next Steps

Database Configuration

Learn how to configure PostgreSQL and JPA settings

Security Setup

Configure authentication and protect your endpoints

API Reference

Explore the available API endpoints

Quick Start

Follow a quick tutorial to get started

Build docs developers (and LLMs) love