DEV Community

loizenai
loizenai

Posted on • Edited on

2

Spring JPA + PostgreSQL + AngularJS example | Spring Boot

https://ozenero.com/spring-jpa-postgresql-angularjs-example-spring-boot

https://ozenero.com/spring-boot-spring-security-jwt-authentication-architecture-tutorial

Spring JPA + PostgreSQL + AngularJS example | Spring Boot

In this tutorial, JavaSampleApproach shows you a Spring Boot example that uses Spring JPA to interact with PostgreSQL and AngularJS as a front-end technology to make request and receive response.

Related Posts:

I. Overview

1. Goal

spring-jpa-postgresql-angularjs-structure

We'll build a Spring Boot Application in that:

  • REST Service provides interface for interacting with Customer Database (PostgreSQL) using Spring JPA.
  • By using AngularJS to make HTTP request to REST Service and receive response, UI can save Customer Data (id, firstName, lastName), retrieves and displays:
  • All Customers in database.
  • Customer Data by customerId.
  • Customers List by lastName.

    2. Technology

  • Java 1.8
  • Maven 3.3.9
  • Spring Tool Suite – Version 3.8.4.RELEASE
  • Spring Boot: 1.5.4.RELEASE

    3. Project Structure

    spring-jpa-postgresql-angularjs-project-structure

Our Application has 2 main parts: REST Service & UI

  • REST Service:
  • Customer Class corresponds to entity and table customer, it should be implemented Serializable.
  • CustomerRepository is an interface extends CrudRepository, will be autowired in CustomerController for implementing repository methods and custom finder methods.
  • CustomerController is a REST Controller which has request mapping methods for RESTful requests such as: /postcustomer, /findall, /customer/{id}, /findByLastName.
  • Configuration for Spring Datasource and Spring JPA properties in application.properties.
  • Response class defines structure for returned data of HTTP GET.

To understand deeply the code about JPA that uses in this example, please visit:
How to use Spring JPA with PostgreSQL | Spring Boot

  • UI: uses AngularJS for HTTP POST/GET requests:
  • home.jsp contains elements for POST/GET request and display results.
  • controller() and $http.get()/$http.post() methods in angular.js Javascript file.
  • WebController maps url to home.jsp page.

https://ozenero.com/spring-jpa-postgresql-angularjs-example-spring-boot

Spring JPA + PostgreSQL + AngularJS example | Spring Boot

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay