Posted in Spring Boot Spring Core

Spring Boot application.properties Inheritance/Override

Table of Contents Introduction Prerequisites Project Setup Inheritance/Override Testing The Application Source Code Introduction In this example I am going to show you how to inherit values from application.properties into different environments. So, if you have an application.properties file under class path folder src/main/resources and if you have different environment specific application-{env}.properties files, then you csan inherit key/value pairs from application.properties file. Even you can override the inherited key/value…

Continue Reading... Spring Boot application.properties Inheritance/Override
Posted in Kafka Spring Boot Spring Cloud

Spring Cloud Bus Example

Here I am going to build an application to show how to use Spring Cloud Bus. Let’s say you have multiple applications reading properties using Spring Cloud Config from centralized configuration files (for example, from Git repository). Spring Cloud Config is where you can have not only your all configurations centrally managed but also you can refresh them dynamically and…

Continue Reading... Spring Cloud Bus Example
Posted in Spring Boot Spring Cloud

Spring Centralized Runtime Properties Configuration without refreshing the Client

Introduction This tutorial walks you through the process of consuming the configurations from the Spring cloud config server. So I will setup a config server and build a client application consumes the configuration on startup and then refreshes the configuration without restarting the client. Let’s say you have some configuration values, in application properties or yaml/yml files, which may be…

Continue Reading... Spring Centralized Runtime Properties Configuration without refreshing the Client
Posted in Spring Core

Conditional Statement in Spring Config

Sometimes we may need to have some conditional statement in Spring config XML file depending upon some variables value. Think of a situation when you are using JPA in your application and your application may have two persistence units in Spring XML config file and you need to connect to one of them depending upon the environments. Here conditional statement…

Continue Reading... Conditional Statement in Spring Config
Posted in Java Spring Core

Compound Property Names in Spring

With this example I will show you how compound or nested property names work in Spring application. Compound or nested property names are perfectly legal when setting bean properties, as long as all components of the path except the final property name are non-null. You can use compound or nested property names when you set bean properties, as long as…

Continue Reading... Compound Property Names in Spring
Posted in Java Spring Core

Working with Collection Element Props in Spring Application

With this example I will show you how to inject Collections type Props in Spring applications. This is similar to the element type Map I had shown in another example. I am going to use Spring Boot framework but I will show you both using application.properties file as well as traditional XML config file to configure the props elements. In…

Continue Reading... Working with Collection Element Props in Spring Application
Posted in MySQL Spring JDBC

Call Stored Procedure Using Spring StoredProcedure

Stored Procedure This tutorial will show you how you can call stored procedure using Spring StoredProcedure. I assume you have a basic idea about stored procedure and what a stored procedure does and what are the advantages of using stored procedure in database server. Related Posts: Sometimes you may need to call a stored procedure while a single SQL statement…

Continue Reading... Call Stored Procedure Using Spring StoredProcedure
Posted in MySQL Spring JDBC

Call Stored Procedure using Spring SimpleJdbcCall

Simple Jdbc Call This tutorial will show you how you can call or execute stored procedure using Spring SimpleJdbcCall. SimpleJdbcCall API provides flexible methods to invoke stored procedure. You can use DataSource directly with SimpleJdbcCall or you can create JdbcTemplate using DataSource and use JdbcTemplate with SimpleJdbcCall API for calling the stored procedures. You can also use RowMapper or BeanProprtyMapper…

Continue Reading... Call Stored Procedure using Spring SimpleJdbcCall
Posted in Java Spring Core

Injecting properties value in Spring

This tutorial will show you how we can auto inject value from properties file in Spring. For this tutorial we will create a standalone maven project in Eclipse. If you already have an idea on how to create a maven project in Eclipse will be great otherwise I will tell you here how to create a maven project in Eclipse….

Continue Reading... Injecting properties value in Spring