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 we 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 which may be changed during runtime and it is not possible always to restart your application and change the configuration values. Here Spring configuration helps us to externalize our properties or configurations.

Continue

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 in Spring config comes to rescue. For example, when you write code in your local system and want to test the application then you do not want to connect to…

Continue

Compound property names in Spring

With this example we will show you how compound or nested property names work in Spring. You can use compound or nested property names when you set bean properties, as long as all components of the path except the final property name are not null. 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

Collection element props in Spring

With this example we will show you how to inject Collections in Spring Bean properties. In order to show how Collections can be injected in a Spring Bean we will create a simple Spring Bean with a property Properties. 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. Prerequisites The following things are required in order to run the application Eclipse Kepler JDK 1.8 Have maven 3…

Continue

Call Stored Procedure using Spring StoredProcedure

This tutorial will show you how we can call stored procedure using Spring StoredProcedure. I assume you have a basic idea on stored procedure what it does and what are the advantages of using stored procedure. I am going to build the project using both maven and gradle build tools. Related Posts: Call Stored Procedure using Spring SimpleJdbcCall Sometimes we need to call a stored procedure while a single SQL statement is unable to fulfil our requirements because, it permits to execute multiple SQL statements and it also allows us…

Continue

Call Stored Procedure using Spring SimpleJdbcCall

This tutorial will show you how we can call or execute stored procedure using Spring SimpleJdbcCall. SimpleJdbcCall API provides flexible methods to invoke stored procedure. We can use DataSource directly with SimpleJdbcCall or we can create JdbcTemplate using DataSource and use JdbcTemplate with SimpleJdbcCall API for calling the stored procedures. We can also use RowMapper or BeanProprtyMapper of type POJO class as a return type while executing stored procedures using Spring’s SimpleJdbcCall API. We are also going to use @Qualifier annotation for resolving ambiguity while using SimpleJdbcCall with DataSource and…

Continue

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. Prerequisites The following things are required in order to run the application Eclipse Helios JDK 1.6 Have maven installed and configured Spring dependencies in pom.xml Now we will see the…

Continue