Spring Boot + Angular 6 example | Spring Data JPA + REST + MySQL CRUD example
Tags: angular, springboot, mysql, crud
Published: 2021-05-19 04:41:52

https://grokonez.com/spring-framework/spring-data/spring-boot-angular-6-example-spring-data-jpa-rest-mysql-crud-example

Spring Boot + Angular 6 example | Spring Data JPA + REST + MySQL CRUD example

In this tutorial, we show you Angular 12 Http Client & Spring Boot Server example that uses Spring JPA to do CRUD with MySQL and Angular 12 as a front-end technology to make request and receive response.

Related Posts:
- <a href="https://grokonez.com/spring-framework/spring-boot/use-spring-jpa-mysql-spring-boot">How to use Spring JPA MySQL | Spring Boot</a>

Update for Angular 8:
<a href="https://grokonez.com/spring-framework/spring-boot/spring-boot-angular-8-example-crud-mysql-spring-restapis-angular-http-client-tutorial">Spring Boot 2.1 + Angular 8 + MySQL example | Angular HTTP Client + RestAPIs + Spring JPA CRUD + MySQL tutorial</a>

You may like this series:
<a href="https://grokonez.com/spring-framework/spring-boot/angular-spring-boot-jwt-authentication-example-angular-6-spring-security-mysql-full-stack-part-1-overview-and-architecture">Angular Spring Boot JWT Authentication example | Angular 12 + Spring Security + MySQL Full Stack</a>

<!--more-->
<h2>I. Technologies</h2>
– Java 1.8
– Maven 3.3.9
– Spring Tool Suite – Version 3.8.4.RELEASE
– Spring Boot: 2.0.3.RELEASE
– Angular 12
- RxJS 6
<h2>II. Overview</h2>
<h3>Demo</h3>

<iframe width="853" height="480" src="https://www.youtube.com/embed/z5fG_PDAAYE?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

<img src="https://grokonez.com/wp-content/uploads/2017/05/angular-http-service-architecture-1.png" alt="angular-http-service-architecture" width="570" height="542" class="alignnone size-full wp-image-5475" />
<h3>1. Spring Boot Server</h3>
<img src="https://grokonez.com/wp-content/uploads/2018/06/spring-boot-angular-6-spring-rest-api-data-mysql-spring-server-architecture.png" alt="spring-boot-angular-6-spring-rest-api-data-mysql-spring-server-architecture" width="699" height="325" class="alignnone size-full wp-image-13184" />
<h3>2. Angular 12 Client</h3>
<img src="https://grokonez.com/wp-content/uploads/2018/06/spring-boot-angular-6-spring-rest-api-data-mysql-angular-client-architecture.png" alt="spring-boot-angular-6-spring-rest-api-data-mysql-angular-client-architecture" width="696" height="462" class="alignnone size-full wp-image-13185" />
<h2>III. Practice</h2>
<h3>1. Project Structure</h3>
<h4>1.1 Spring Boot Server</h4>
<img src="https://grokonez.com/wp-content/uploads/2018/06/spring-boot-angular-6-spring-rest-api-data-mysql-spring-server-structure.png" alt="spring-boot-angular-6-spring-rest-api-data-mysql-spring-server-structure" width="322" height="362" class="alignnone size-full wp-image-13187" />

- <strong>Customer</strong> class corresponds to entity and table <strong>customer</strong>.
- <strong>CustomerRepository</strong> is an interface extends <strong>CrudRepository</strong>, will be autowired in <strong>CustomerController</strong> for implementing repository methods and custom finder methods.
- <strong>CustomerController</strong> is a REST Controller which has request mapping methods for RESTful requests such as: <code>getAllCustomers</code>, <code>postCustomer</code>, <code>deleteCustomer</code>, <code>deleteAllCustomers</code>, <code>findByAge</code>, <code>updateCustomer</code>.
- Configuration for Spring Datasource and Spring JPA properties in <strong>application.properties</strong>
- <strong>Dependencies</strong> for <strong>Spring Boot</strong> and <strong>MySQL</strong> in <strong>pom.xml</strong>
<h4>1.2 Angular 12 Client</h4>
<img src="https://grokonez.com/wp-content/uploads/2018/06/spring-boot-angular-6-spring-rest-api-data-mysql-angular-client-structure.png" alt="spring-boot-angular-6-spring-rest-api-data-mysql-angular-client-structure" width="251" height="547" class="alignnone size-full wp-image-13188" />

In this example, we focus on:
- 4 components: <strong><em>customers-list</em></strong>, <strong><em>customer-details</em></strong>, <strong><em>create-customer</em></strong>, <strong><em>search-customer</em></strong>.
- 3 modules: <strong><em>FormsModule</em></strong>, <strong><em>HttpClientModule</em></strong>, <strong><em>AppRoutingModule</em></strong>.
- <strong><em>customer.ts</em></strong>: class Customer (id, firstName, lastName)
- <strong><em>customer.service.ts</em></strong>: Service for Http Client methods
<h3>2. How to do</h3>
<h4>2.1 Spring Boot Server</h4>
<h5>2.1.1 Dependency</h5>

https://grokonez.com/spring-framework/spring-data/spring-boot-angular-6-example-spring-data-jpa-rest-mysql-crud-example

Spring Boot + Angular 6 example | Spring Data JPA + REST + MySQL CRUD example