Home » Spring

Tag Archives: Spring

Quick tip: Referencing other Properties in Spring

spring-interview-questions-answers

In Spring property (or yaml) files we can reference other properties using the ${..} syntax. For example: 1 2 3 external.host=https://api.external.com external.productService=${external.host}/product-service external.orderService=${external.host}/order-service If we now access the external.productService property (e.g. by using the @Value annotation) we will get the value https://api.external.com/product-service. For example: 1 2 @Value("${external.productService}") private String productServiceUrl; // https://api.external.com/product-service This way we can avoid duplication of commonly used values in property ...

Read More »

What is Bean scope in Spring MVC framework with Example

spring-interview-questions-answers

Bean scope in Spring framework or Spring MVC is scope for a bean managed by Spring IOC container. You may know that Spring is a framework that is based on Dependency Injection and Inversion of Control and provides bean management facilities to Java application. In Spring-managed environment bean (Java Classes) are created and wired by the Spring framework. Spring allows ...

Read More »

Integrating JSON Schema validation in Spring using a custom HandlerMethodArgumentResolver

In previous posts we learned about JSON Schema and how we can validate a JSON document against a JSON Schema in Java. In this post we will integrate JSON Schema validation into Spring controllers using a custom HandlerMethodArgumentResolver. We will use the same JSON document and JSON Schema as in previous posts. So, what is a HandlerMethodArgumentResolver? Handler methods in ...

Read More »

10 JdbcTemplate Examples in Spring Framework

spring-interview-questions-answers

Hello guys, If you have been using the Spring framework then you may know that the JdbcTempalte is one of the most useful classes of Spring framework. The JdbcTempalte class provides lots of convenient methods for performing database-related tasks that take the pain away from using the JDBC API. If you have worked in any real-life JAva project which connects to Database ...

Read More »

RESTful services with HATEOAS: REST APIs and Hypermedia on JVM

java-interview-questions-answers

1. Introduction So far we have spent a fair amount of time talking about the role of the hypermedia and HATEOAS in the RESTful web services and APIs, glancing over different specifications and usability aspects. It sounded like supporting hypermedia and HATEOAS is not that difficult, just pick you favorites and you are good to go! As you may guess, ...

Read More »

Using Multiple Dynamic Caches With Spring

spring-interview-questions-answers

In a third post about cache managers in spring (over a long period of time), I’d like to expand on the previous two by showing how to configure multiple cache managers that dynamically create caches. Spring has CompositeCacheManager which, in theory, should allow using more than one cache manager. It works by asking the underlying cache managers whether they have ...

Read More »

AWS DynamoDB version field using AWS SDK for Java 2

spring-interview-questions-answers

It is useful to have a version attribute on any entity saved to anAWS DynamoDB database which is simply a numeric indication of the number of times the entity has been modified. When the entity is first created it can be set to 1 and then incremented on every update.  The benefit is immediate – an indicator of the number ...

Read More »