My Articles:
While working on Node you may be downloading various npm packages. Sometimes the download process just hung and does not move forward. You may also see errors related to non-reachable registry.npmjs.org URL. 1. Error Log Typically error logs look like this: 2. Solution Mostly (and for me as well) this …
Learn to use Spring RestTemplateBuilder to create or build RestTemplate bean which can be used to send HTTP requests. 1. Default RestTemplateBuilder To inject RestTemplateBuilder, pass it as a constructor argument in the service class. 2. Custom RestTemplateBuilder To create custom RestTemplateBuilder, create @Bean of type RestTemplateBuilder in Spring context. …
In this Spring boot rest interceptor example, learn to use ClientHttpRequestInterceptor with Spring RestTemplate to log request and response headers and body in Spring AOP style. 1. Spring REST Interceptor Usages We can use this interceptor for many useful tasks. 2. REST Interceptor to Log Requests and Responses Below given …
Learn to create a Java List with only one element in it using Arrays.asList() and Collections.singletonList() methods.
Learn to use log4j LevelRangeFilter filter which returns the onMatch result if the level in the LogEvent is in the range of the configured min and max levels, otherwise it returns onMismatch value. LevelRangeFilter Configuration In given log4j2.xml file, we have used to LevelRangeFilter to filter log levels in such …
Given log4j2.xml is reference to configure multiple appenders such as console appender and file appenders. This also configure the dynamic log root path. Log4j2 Multiple Appenders – XML Configuration Sample log4j2 configuration is given blow. It does following things: Uses dynamic log root path where log files will be created. …
Learn to use Spring @Async with @EnableAsync to create non-blocking REST controllers in a Spring Boot application.
Spring boot log4j2.xml configuration example of configuring log4j2 with spring boot2 project and adding logging support to the application.
Learn to append the data to a file in Java using Standard IO’s BufferedWritter, PrintWriter, FileOutputStream and NIO Files classes.
Learn to write text and binary data into files using Java Writer, FileChannel, ByteBuffer, Files.write() and writeString() methods in Java 8 and Java 11.
After Java 9 release, Java 10 came very quickly. Unlike it’s previous release, Java 10 does not have that many exciting features, still it has few important updates which will change the way you code, and other future Java versions.
Starting from Java 10, Oracle has adapted time based version-string scheme [JEP 322]. The new time-based model has replaced the feature-based, multi-year release model of the past. Unlike the old releases, the new time-based releases will not be delayed and features will be released every six months, with no constraints …
Java var keyword allows declaring a variable without explicitly specifying its type. Instead, the type of the variable is inferred by the compiler based on the context in which it is used.
Inside a Java program, we can write a special text that will be ignored by the Java compiler — known as the comment. Comments allow us to exclude code from the compilation process (disable it) or clarify a piece of code to yourself or other developers. Learn everything about Java comments, …
In traditional programming languages, such as Java, a variable is a placeholder for storing a value of a particular type: a string, a number, or something else. This Java tutorial discusses what a variable is and the types of variables. Also, look at the example of how to declare a variable in Java. We …
JDK, JRE and JVM is very common words when developers talk about java applications and their development environments. Let’s find out the differeneces between these words.
Python string.endswith() is used to check the end of a string for specific text patterns e.g. domain name extensions and so on.
Python string.startswith() method is used to check the start of a string for specific text patterns e.g. URL schemes and so on.
Python example to split string into tokens using the delimiters in the string. Learn to split string using single or multiple delimiters in python.
Python examples to find common keys between two dictionaries i.e. dictionary intersection items. Learn to compare two dictionaries keys and values.
Learn the differences between a dictionary and OrderedDict, and also how to create, update and delete the items from the Python OrderedDict.
Learn to implement a priority queue in Python using the queue.PriorityQueue class, heapq and bisect modules with examples.
Python examples to find the largest (or the smallest) item in a collection (e.g. list, set or array) of comparable elements using max() and min() methods.
Python examples to find the largest (or the smallest) N elements from a collection of elements using nlargest() and nsmallest() functions from heapq library. 1. Using heapq module’s nlargest() and nsmallest() Python heapq module can be used to find N largest or smallest items from collections. It has two functions …
Python example to unpack tuple or sequence or iterable such that the tuple may be longer than N elements, causing a “too many values to unpack” exception.
The ContextLoaderListener creates the root application context and will be shared with child contexts created by all DispatcherServlet contexts.
SSLHandshakeException appear in logs when there is some error occur while validating the certificate installed in client machine with certificate on server machine. In this post, we will learn about fixing this if you are using Apache HttpClient library to create HttpClient to connect to SSL/TLS secured URLs.
We have already gone through the RestTemplate examples for accessing REST APIs inside spring application. In this example, we are extending the configuration to use Apache HttpClient 4. The purpose of this tutorial is to give you pre-cooked recipe for little head-start, and save you from writing all bits and pieces.
Simple and easy-to-understand examples of sorting a HashMap by values, using Java 8 Stream, in ascending and descending (reverse) orders.
Simple and easy-to-understand examples to sort a Map by key, using TreeMap and Java 8 Stream, in ascending and descending (reverse) orders.
Masking sensitive information is very practical need of applications which deal with sensitive customer data. For example, banking applications. When these applications run inside organization intra-net, many times UI logs are generated and stored on user’s machine for debugging purpose. In above scenario, it is regulatory requirement to mask all …
In java garbage collection tutorial, we will learn about object life cycle, difference between mark-sweep, mark-sweep-compact and mark-copy mechanisms, different single threaded and concurrent GC algorithms (e.g. G1), and various flags to control the gc algorithm’s behavior and log useful information for applications.
Till Java 8, String in java were internally represented by char[]. Each char is stored in 2 bytes in memory. JDK developers at oracle analyzed lots of client’s application help dumps and they noticed that most of the strings can be represented only using Latin-1 characters set. A latin-1 char can be stored in one byte, which is 50% (1 byte) less than char data type storage.
The Spring boot dev tools module provides a lot of useful developer features for improving the development experience such as caching static resources, automatic restarts, live reload, global settings and running the remote applications. 1. Enabling Dev Tools Module Enabling dev tools in the spring boot application is very easy. …
In Spring boot applications, the default packaging is jar which is deployed in embedded servers. Learn to generate a war file for deployment.
Learn to validate domain objects in Spring Boot REST Controller and add custom error messages in API responses related to validation errors.
String boot is very easy to use and it does a lot of things under the hood, you might not be aware of. In future, a good developer will be who will know exactly what is going on behind spring boot auto configuration, how to use it in your favor and how to disable certain sections which you do not want into your project.
In this Spring Boot HATEOAS example, we will learn to add HATEOAS (Hypertext as the Engine of Application State) links to resource representations returned from REST APIs in a Spring boot application. 1. What is HATEOAS? HATEOAS is one of the constraints of the REST architectural style first presented by …
The spring-boot-starter-parent is a special project that provides default configuration and default dependencies for Spring Boot-based applications.
Learn to use three tools for monitoring spring cloud based microservices i.e. Hystrix dashboard, Eureka admin dashboard and Spring boot admin dashboard.
Swagger can be integrated with REST APIs in below ways – A top-down approach – First API specification and then code generation. A botton-up approach – First API code and then Swagger integration. In this tutorial, we will learn the top down approach.
Learn to create fat or uber jar or war build for spring boot applications using the spring-boot-maven-plugin with an example.
Learn to resolve the InputMismatchException by reading the typesafe user inputs from the console in any interactive java application.
Learn to compare double or compare float to avoid unexpected results caused by minor rounding errors during conversions at lower level program execution.
Spring @Lazy allows lazy bean creation either to specific beans or we can configure the lazy loading globally at the application level.
Learn to create define and create spring beans and populate application context in any spring application. This example uses xml config to define beans,
Spring Boot 3 Actuator example to discuss default auto-configuration and monitor and manage our applications in a production-ready manner.
Learn to build spring boot SOAP client in Spring boot applications and consume SOAP web services using WebServiceTemplate and auto client proxy code generation.
Spring CORS helps in serving web content from multiple domains into browsers who usually have the same-origin security policy. In this example, we will learn to enable CORS support in Spring MVC application at method and global level.
In this spring boot soap tutorial, we will focus only in the Spring boot related configurations to see how easily we can create our contract first SOAP webservice.