Angular 6 HttpClient + Spring Boot + MariaDB example | Spring Data JPA + RestAPIs CRUD example
Tags: angular, springboot, restapi, mariadb
Published: 2021-05-19 10:31:45

https://grokonez.com/frontend/angular/angular-6/angular-6-httpclient-spring-boot-mariadb-example-spring-data-jpa-restapis-crud-example

Angular 6 HttpClient + Spring Boot + MariaDB example | Spring Data JPA + RestAPIs CRUD example

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

Related Posts:
- <a href="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</a>
- <a href="https://grokonez.com/spring-framework/spring-data/spring-boot-angular-6-example-spring-data-rest-postgresql-example">Spring Boot + Angular 6 example | Spring Data JPA + REST + PostgreSQL CRUD example</a>
- <a href="https://grokonez.com/spring-framework/spring-data/spring-boot-angular-6-example-spring-data-rest-cassandra-crud-example">Spring Boot + Angular 6 example | Spring Data + REST + Cassandra CRUD example</a>
- <a href="https://grokonez.com/spring-framework/use-spring-jpa-postgresql-spring-boot">How to use Spring JPA with PostgreSQL | Spring Boot</a>

Related Pages:

<ul>
<li><a href="https://grokonez.com/angular-tutorial">Angular</a></li>
<li><a href="https://grokonez.com/spring-framework-tutorial/spring-boot">SpringBoot</a></li>
</ul>

<!--more-->
<h2>I. Technologies</h2>
– Java 1.8
– Maven 3.3.9
– Spring Tool Suite – Version 3.9.4.RELEASE
– Spring Boot: 2.0.4.RELEASE
– Angular 6
- RxJS 6
- MariaDB
<h2>II. Overview</h2>

<img src="https://grokonez.com/wp-content/uploads/2018/08/spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb-angular-http-service-architecture.png" alt="spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb + angular-http-service-architecture" width="570" height="542" class="alignnone size-full wp-image-14191" />
<h3>1. Spring Boot Server</h3>
<img src="https://grokonez.com/wp-content/uploads/2018/08/spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb-spring-server-architecture.png" alt="spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb + spring-server-architecture" width="699" height="325" class="alignnone size-full wp-image-14192" />
<h3>2. Angular 6 Client</h3>
<img src="https://grokonez.com/wp-content/uploads/2018/08/spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb-angular-client-architecture.png" alt="spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb + angular-client-architecture" width="696" height="462" class="alignnone size-full wp-image-14193" />
<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/08/spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb-springboot-structure.png" alt="spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb + springboot-structure" width="339" height="362" class="alignnone size-full wp-image-14194" />

- <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>MariaDB</strong> in <strong>pom.xml</strong>
<h4>1.2 Angular 6 Client</h4>
<img src="https://grokonez.com/wp-content/uploads/2018/08/spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb-angular-client-structure.png" alt="spring-boot-angular-6-httpclient-spring-rest-api-data-mariadb + angular-client-structure" width="251" height="547" class="alignnone size-full wp-image-14195" />

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

More at:

https://grokonez.com/frontend/angular/angular-6/angular-6-httpclient-spring-boot-mariadb-example-spring-data-jpa-restapis-crud-example

Angular 6 HttpClient + Spring Boot + MariaDB example | Spring Data JPA + RestAPIs CRUD example