How to Install Lombok

What is Lombok

Lombok is a great way to have boiler-plate code, especially getters and setters generated on the fly for you. The result is a clean and pithy bean definition.

Download the Lombok

Download the Lombok jar from Project Lombok’s home page: ProjectLombok
Navigate (cd) to the downloaded location.
Find and Execute the Lombok Jar as follows from the command line/terminal.

​java -jar lombok-1.16.6.jar
​function helloWorld(str) {
    document.open();
    document.write(str);
    document.close();
}
helloWorld('

Hello, World!

');

installation

The Lombok executable will scan the installation directory to find if an Eclipse installable exists. It might complain the “I can’t find any IDEs on your computer .. use “Specify Location”…”. In this case, you can specify your own location.

To do so, click “Specify Location…”.
​Now navigate to the eclipse.ini file of your eclipse. E.g. When I am using STS, I have my eclipse *.ini located here.
​/Development/sts-bundle/STS/Contents/Eclipse/STS.ini

Proceed with Installation now.

Once done, launch your eclipse. Add lombok to your classpath if not already added. When using maven’s managed dependency, the following dependency can be added.

    
        org.projectlombok
        lombok
        {your-lombok-version-here}
    

Restart Eclipse

Restart your eclipse if the settings have not taken place. That’s it. You are now setup to use all features of lombok in your favorite coding IDE.

Here is a sample class using lombok’s Data property. This will generate getters and setters for you – so a getDay method is available for use – even though it is not visible here.

package com.example.boot.diner;

import lombok.Data;

@Data public class TrivialDinerRequest {

    private String day;

}

Angular 14 Spring Boot JWT Authentication example | Angular 14 + Spring Security + MySQL Full Stack – Part 3: Build Frontend

The tutorial is Part 3 of the series: Angular Spring Boot JWT Authentication example | Angular 14 + Spring Security + MySQL Full Stack. Today we’re gonna build a Angular HTTP Client App that can interact with SpringBoot JWT Authentication Server.

Part 1: Overview and Architecture.
Part 2: Build SpringBoot Backend

Continue reading “Angular 14 Spring Boot JWT Authentication example | Angular 14 + Spring Security + MySQL Full Stack – Part 3: Build Frontend”

Angular 14 Firestore tutorial with CRUD application example – @angular/fire

[no_toc]Tutorial: Angular 14 Firestore tutorial with CRUD application example – @angular/fire

Cloud Firestore helps us store data in the cloud. It supports offline mode so our app will work fine (write, read, listen to, and query data) whether device has internet connection or not, it automatically fetches changes from our database to Firebase Server. We can structure data in our ways to improve querying and fetching capabilities. This tutorial shows you how to work with Firebase Firestore along with an Angular app that can do CRUD Operations.

Related Posts:
Angular 14 Firebase tutorial: Integrate Firebase into Angular 14 App with @angular/fire
Angular 14 Firebase CRUD operations with @angular/fire
Angular 14 – Upload/Display/Delete files to/from Firebase Storage using @angular/fire

Continue reading “Angular 14 Firestore tutorial with CRUD application example – @angular/fire”

MicroService iCommerce APIs – MVP (SpringBoot + Java 11)

Overview System Architecture

Microservice-iCommerce-System-Architecture
Microservice-iCommerce-System-Architecture

MVP iCommerce Service

Tech Stack

  • SpringBoot
  • Java 11
  • PostgreSQL
  • ElasticSearch
  • Docker

MVP Architecture

iCommerce-MVP-Service
iCommerce-MVP-Service

Database Design

Database Design
Database Design

API Details

We have 2 main groups of APIs:
– Authentication-API: Sign-in/Sign-Up APIs
– Functional APIs: Filter Products API / Card-Items APIs
Others API:
– Initial Data API for Demo
– ElasticSearch API for retrieve data

Authentication-SignUp API

– API-URL: http://localhost:9009/icommerce-service/api/auth/signup/

SignUp API
SignUp API

Authentication-Signin API

– API-URL: http://localhost:9009/icommerce-service/api/auth/signin/

Sign-In API
Sign-In API

– Header:

Header Authorization JWT Token
Header Authorization JWT Token

Initial-Data API

curl --location --request GET 'http://localhost:9009/icommerce-service/api/init' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYWNrX3NtaXRoIiwiaWF0IjoxNjYwMzkwNzAyLCJleHAiOjE2NjAzOTE3MDJ9.H4mJNeRcH1Nc7AUzFIQ8SzrJUtJMl9xct08fDcu9BCenxBsfrX5teVlOjDLScp8vNyGTYq9jBoSvbdcKGrJ63A' \

*Note: using JWT of ADMIN for initial data

Filter Products API

curl --location --request POST 'http://localhost:9009/icommerce-service/api/filter' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYWNrX3NtaXRoIiwiaWF0IjoxNjYwMzgzNzIwLCJleHAiOjE2NjAzODQ3MjB9.oO9uINuKVxFTQ6vZmSXz8Q8eOttk3hESQEDL8YiLqTZ0d3m5RJRGkkXQlgihozSRmf2Up1X8zaPQOjPv0QjT2g' \
--header 'Content-Type: application/json' \
--data-raw '{
    "brand": "Ginger & Smart",
    "category": "JEANS",
    "color": "RED",
    "price_min": 0,
    "price_max": 1000,
    "page": {
        "page": 0,
        "size": 10
    }
}'

– Filter by: Brand, Category, Price and Colors.
* Note: No need using JWT Authorization Header when using the filtering API.

Shopping Card API

Adding a Card
curl --location --request POST 'http://localhost:9009/icommerce-service/api/card/add' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYWNrX3NtaXRoIiwiaWF0IjoxNjYwMzkwNzAyLCJleHAiOjE2NjAzOTE3MDJ9.H4mJNeRcH1Nc7AUzFIQ8SzrJUtJMl9xct08fDcu9BCenxBsfrX5teVlOjDLScp8vNyGTYq9jBoSvbdcKGrJ63A' \
--header 'Content-Type: application/json' \
--data-raw '{
    "product_id": 1,
    "color": "WHITE",
    "quantity": 10
}'
Retrieve All Card-Items
curl --location --request GET 'http://localhost:9009/icommerce-service/api/card/all' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYW5lX2pvaG5zb24iLCJpYXQiOjE2NjAyOTkzNzQsImV4cCI6MTY2MDMwMDM3NH0.1qGGAZmquvByMlrA4ly3Sf_OVKPRv-2FOdiDVS3cxG-X48-OjqCf2Lp1RWdpP7o1pdd9k8bVxKWNK2npr9EAjQ' \
--header 'Content-Type: application/json' 
Retrieve a Card-Item by ID
curl --location --request GET 'http://localhost:9009/icommerce-service/api/card/all' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYW5lX2pvaG5zb24iLCJpYXQiOjE2NjAyODEzNzgsImV4cCI6MTY2MDI4MjM3OH0.YOkCscyoAJEJgI_QHliYM8wmUgGhpresW2nOFFqOtoq-N1bOXB9r0CexbmDwZPquYnwrheUl0H_HW4pCxxBkCg' \
--header 'Content-Type: application/json'
Modify a Card-Item
curl --location --request PUT 'http://localhost:9009/icommerce-service/api/card/modify' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYW5lX2pvaG5zb24iLCJpYXQiOjE2NjAyODEzNzgsImV4cCI6MTY2MDI4MjM3OH0.YOkCscyoAJEJgI_QHliYM8wmUgGhpresW2nOFFqOtoq-N1bOXB9r0CexbmDwZPquYnwrheUl0H_HW4pCxxBkCg' \
--header 'Content-Type: application/json'
Delete Card Item by ID
curl --location --request DELETE 'http://localhost:9009/icommerce-service/api/card/remove/3' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYW5lX2pvaG5zb24iLCJpYXQiOjE2NjAyODEzNzgsImV4cCI6MTY2MDI4MjM3OH0.YOkCscyoAJEJgI_QHliYM8wmUgGhpresW2nOFFqOtoq-N1bOXB9r0CexbmDwZPquYnwrheUl0H_HW4pCxxBkCg' \
--header 'Content-Type: application/json' 
Delete All Cards
curl --location --request DELETE 'http://localhost:9009/icommerce-service/api/card/remove/3' \
--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqYW5lX2pvaG5zb24iLCJpYXQiOjE2NjAyODEzNzgsImV4cCI6MTY2MDI4MjM3OH0.YOkCscyoAJEJgI_QHliYM8wmUgGhpresW2nOFFqOtoq-N1bOXB9r0CexbmDwZPquYnwrheUl0H_HW4pCxxBkCg' \
--header 'Content-Type: application/json'

Postman-API-URL for Importing

https://www.postman.com/collections/eb2c7f9de2a7ca9e63d2

Overview Project

Icommerce Project Structure
Icommerce Project Structure

Testing

Starting Elastic-Search + Postgres by Docker-Compose file by cmd:
docker-compose up

Run Test-Class: IcommerceServiceApplicationTests

I design 2 test-cases for Filtering-API and set of Card-APIs:

    @BeforeEach
    void setup(){
    	doSetup();
    }
	
    @Test
    @WithMockUser(username="jane_johnson",roles={"USER"})
    void testcase_CardItems() throws Exception{
    	do_Testcase_CardItem();
    }
    
    @Test
    void testcase_Filter() throws Exception{
    	doTestcase_Filter();
    }
Running Test-cases
Running Test-cases

Deploy & Running Web APP

First start Elastic-Search & Postgres by Docker Compose by using CMD:
docker-compose up
*Note: we can down all services (ES & Postgres) by cmd: docker-compose down

Then using cmd to build Web-APP: mvn clean install -U
Finally, run it by cmd: mvn spring-boot:run

Then import Postman – API to enjoy the MVP-APIs.

Sourcecode

GIT-HUB.

The Benefits of Learning to Code

You have probably clicked on this guide because you are thinking about learning all the ins and outs of coding but are not sure as to whether the benefits involved are worth it. This is something worth thinking about when you consider that it takes around three to six months to learn just the very basics of coding. Nonetheless, it can easily be argued that the benefits of learning to code are manifold and make it a worthwhile investment. If you want to know what they are, then you are in the right place, as this guide will give you a complete overview.

Increases Intelligence

If you are looking to become more intelligent and simply just boost your smartness in general, then learning to code is a great idea. As it is a rather challenging experience, this means that if you do succeed in it, you will feel a great sense of accomplishment, boosting your mental health in the process, with studies even suggesting that people who learn to code are less likely to develop early-onset dementia. If you are looking to code, however, then you need to make sure that you have a good laptop and that it is transported safely. For sending delicate items, take a look around now for a great fragile goods transport service today.

Makes You More Employable

As the cost of living has gone up in the USA, it is more important than ever to have a high-paying job that can allow you to pay the bills no matter what you are doing or where you are living. This means that if you have the qualifications in particular coding languages, this means that you have something to talk about when it comes to a job interview. This means that you will definitely be a lot more employable, especially in high-paying tech jobs with a lot of great perks!

Transferrable Skills

When you learn how to code, this doesn’t necessarily mean that you have to get a job in website development or computer security. In fact, it doesn’t necessarily mean that you need to get a coding-related job at all. What coding does offer you, however, is one of the most transferrable skills out there. This means that even if you work in management or development, having that coding knowledge in your back pocket can help you massively.

Create Your Own Product

Programming, coding, and software development are all closely linked. This means that if you know to code, you will be able to actually think about making your own product or solution. The benefit of doing this is the vast economic potential of such a decision, as well as the fun and satisfaction that you will get out of solving a problem. Try and think now about a certain type of product or solution that you would like to see on the market; it’s likely that if you learn how to code, you might just be able to make that product a reality yourself.