Skip to content

Instantly share code, notes, and snippets.

View codedeep79's full-sized avatar

Nguyễn Trung Hậu codedeep79

View GitHub Profile
@codedeep79
codedeep79 / Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found.md
Last active July 18, 2022 02:16
Plugin 'org.springframework.boot:spring-boot-maven-plugin:' not found

Add following code:

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${parent.version}</version>
    </plugin>

and then click on the icon as shown in screenshot, to load Maven changes in pom.xml file

@codedeep79
codedeep79 / Ví dụ về BiConsumer trong Java 8.md
Created July 20, 2022 08:37
Ví dụ về BiConsumer trong Java 8

In Java 8, BiConsumer is a functional interface; it takes two arguments and returns nothing.

@FunctionalInterface
public interface BiConsumer<T, U> {
  void accept(T t, U u);
}

BiConsumer

import java.util.function.BiConsumer;
@codedeep79
codedeep79 / Ví dụ Supplier trong Java 8.md
Created July 20, 2022 09:13
Ví dụ Supplier trong Java 8

In Java 8, Supplier is a functional interface; it takes no arguments and returns a result.

  • Supplier.java
@FunctionalInterface
public interface Supplier<T> {
    T get();
}

Supplier

This example uses Supplier to return a current date-time.

@codedeep79
codedeep79 / Ví dụ về MinguoDate trong Java 8.md
Last active August 3, 2022 08:13
Ví dụ về MinguoDate trong Java 8

This MinguoDate calendar system is primarily used in Taiwan (Republic of China…)

To convert the current date to the Minguo date, just subtracts the current year with number 1911, for example:

  • LocalDate -> MinguoDate Review a full example to convert a LocalDate to MinguoDate
import java.time.LocalDate;
import java.time.chrono.MinguoDate;

public class TestMinguoDate {
@codedeep79
codedeep79 / Ví dụ về @JsonView trong thư viện Jackson của Java.md
Created July 20, 2022 13:00
Ví dụ về @JSONVIEW trong thư viện Jackson của Java

In Jackson, we can use @JsonView to limit or control fields display for different users.

Maven

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.example</groupId>
@codedeep79
codedeep79 / Xây dựng API cho ứng dụng CRUD với Spring Boot JPA + H2.md
Last active August 3, 2022 08:13
Xây dựng API cho ứng dụng CRUD với Spring Boot JPA + H2

Project Directory

Let me explain it briefly.

  • Tutorial data model class corresponds to entity and table tutorials.
  • TutorialRepository is an interface that extends JpaRepository for CRUD methods and custom finder methods. It will be autowired in TutorialController.
  • TutorialController is a RestController which has request mapping methods for RESTful requests such as: getAllTutorials, createTutorial, updateTutorial, deleteTutorial, findByPublished…
  • Configuration for Spring Datasource, JPA & Hibernate in application.properties.
  • pom.xml contains dependencies for Spring Boot and H2 Database.
@codedeep79
codedeep79 / Database "mem:testdb" not found.md
Created July 21, 2022 03:51
Lỗi Database "mem:testdb" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149

If you are dealing with the Spring Boot project, please change the JDBC URL jdbc:h2:~/test to jdbc:h2:mem:testdb in the login page, which is the default URL configured by Spring Boot.

@codedeep79
codedeep79 / Cài đặt ReactJS trên Ubuntu 20.04.md
Created July 21, 2022 11:40
Cài đặt ReactJS trên Ubuntu 20.04
@codedeep79
codedeep79 / Cài đặt Vue.js trong Ubuntu.md
Last active August 3, 2022 08:08
Cài đặt Vue.js trong Ubuntu

Prerequisites: Install Node.js in Ubuntu

Install npm:

To integrate Vue.js into a project, you can use the CDN package, NPM, or CLI.

Using the CDN Package

If you want to start learning Vue.js, then it is best to use the CDN package. You can simply add the following script tag in your project to get started.