Quantcast
Channel: Mkyong.com
Browsing all 28 articles
Browse latest View live

mysql-connector-java: unknown was not found

The IntelliJ cannot find the mysql-connector-java dependency and hits error "unknown was not found"? pom.xml <dependency> <groupId>mysql</groupId>...

View Article


How to change user agent in wget

This article shows how to use the -U (uppercase U) option to change the user agent in wget command. Terminal wget -U {user-agent} {location} Change user agent in wget The below command changes the wget...

View Article


Image may be NSFW.
Clik here to view.

Spring Data JPA Paging and Sorting example

This article shows how to do Spring Data JPA paging and sorting using the PagingAndSortingRepository interface. Technologies used: Spring Boot 3.1.2 Spring Data JPA H2 in-memory database Java 17 Maven...

View Article

Image may be NSFW.
Clik here to view.

Spring Boot @ConditionalOnProperty Example

In Spring Boot, we can use the @ConditionalOnProperty annotation to conditionally register the beans based on the property value in the application.properties or application.yml file. This article will...

View Article

How to restart Nginx on macOS

We open a Terminal and use the one-liner command sudo nginx -s stop && sudo nginx to restart the Nginx on macOS. Restart the Nginx service. Terminal sudo nginx -s stop && sudo nginx...

View Article


Spring Boot @DynamicPropertySource Example

In Spring Boot, we can use @DynamicPropertySource to dynamically register or override property values in the ApplicationContext for integration tests. Tables of contents: 1. Testing with...

View Article

Spring Boot @ServiceConnection Example

Spring Boot 3.1 introduced @ServiceConnection to enable the Spring Boot’s auto-configuration to use the service connection details to connect to a remote service (Testcontainers). Tables of contents:...

View Article

Jackson – Java 8 date/time type `java.time.LocalDate` not supported by default

Try Jackson to convert an object containing the Java 8 time APIs like LocalDate to a JSON formatted string and hits the errors Java 8 date/time typejava.time.LocalDatenot supported by default Book.java...

View Article


Spring Boot CommandLineRunner Example

This article tells what is CommandLineRunner and different ways of implementing it or use it in Spring Boot. Table of contents: 1. What is CommandLineRunner? 2. Implementing CommandLineRunner 3. @Bean...

View Article


How to Run a CommandLineRunner Bean Conditionally in Spring Boot

This article shows different ways to run a CommandLineRunner bean conditionally in a Spring Boot application. Table of contents: 1. Using @ConditionalOnProperty 2. Using Environment 3. Using Spring...

View Article

How to ignore a field with Jackson

In Jackson, we can use @JsonIgnore to ignore a single field, @JsonIgnoreProperties to ignore multiple fields and @JsonIgnoreType to ignore a specified type during JSON serialization and...

View Article

Convert Java Objects to JSON with Jackson

This article will show you how to convert Java objects to JSON with Jackson. Table of contents: 1. Setup Jackson 2. Jackson quick examples 3. Convert Java Object to JSON using Jackson 4. Convert JSON...

View Article

Write JSON to a file with Jackson

This article shows you write JSON to a file with Jackson. Table of contents: 1. Download Jackson 2. Define a Java Object 3. Write JSON to a File 4. Download Source Code 5. References P.S Tested with...

View Article


How to map a subset of a JSON file using Jackson

This article shows how to map a subset of a JSON file using Jackson. Table of contents: 1. Download Jackson 2. Map a subset of a JSON file 3. Define Java Classes that reflect JSON structure 4. Ignoring...

View Article

Jackson and Lombok examples

This article shows how to use Jackson and Lombok together. Table of contents: 1. Download Jackson and Lombok 2. Model with Lombok annotations 3. Parse JSON using Jackson 5. Download Source Code 6....

View Article


How to parse JSON using Moshi

This article shows how to parse JSON using Moshi. Table of contents: 1. Download Moshi 2. Parse JSON using Moshi 3. Parse JSON Array using Moshi 4. Convert Java Object to JSON String 5. Download Source...

View Article

How to write JSON to a file using Moshi

This article shows how to write JSON to a file using Moshi. Table of contents: 1. Download Moshi 2. Write JSON to a file using Moshi 3. Read JSON from a file using Moshi 4. Download Source Code 6....

View Article


Moshi – java.math.BigDecimal requires explicit JsonAdapter to be registered

Moshi does not have built-in adapters to process types like java.math.BigDecimal; we need to manually provide a custom adapter to handle the BigDecimal type. Table of contents: 1. Download Moshi 2....

View Article

How to pretty print JSON using Moshi

This article shows how to use Moshi’s JsonAdaptor indent method to enable the pretty print JSON. Table of contents: 1. Download Moshi 2. Compact print JSON (Default) 3. Pretty print JSON using Moshi 4....

View Article

Moshi java.time.LocalDate requires explicit JsonAdapter to be registered

Moshi does not have built-in adapters to process types like Java 8 date time APIs java.time.* or JSR-310; we need to manually provide a custom adapter to handle the Java 8 date time type. This article...

View Article
Browsing all 28 articles
Browse latest View live