setting list and set values in spring

In this post i’m gonna show you setting List values of pojo by using Spring Framework, it takes less than a minute! FruitBasket.java beans.xml App.java Note: similarly we can use set by replacing list with set in beans.xml, but as you already know set wont allow duplicate values. If you want to set other beans as list ¬†values just use ref tag, like below Output: krishh basket contains: apple banana orange kiwi pear orange If you found an error, highlight it and press Shift + Enter or click here to inform us.

Read more

Spring bean Scope

Scopes are there from the birth of programming language,we call it design patterns. According to gang of4 book there are 3 types of design patterns: Creational, structural, Behavioural design patterns.In creational design pattern there are singleton and prototype pattern and etc are there which we use in certain situations. In spring to use design patterns we don’t need to write code for that we just call it.By default spring is providing those for us. If we create any bean by default its scope is a singleton, If you want to modify the default one you can specify the scope type

Read more

Spring Dependency Injection

DI(Dependency injection) is a very big concept in spring. Which spring inherits it from JEE with reference to JSR 330 which makes us to maximize reusability, testability and maintainability of Java code. Before dependency injection has come into picture developers need to write boiler plate code like below, There is a class named Address.java and Person.java the Person.java will take Address.java as property were Person will return all of it state with to String. Lol! you thought that what is the problem with it? there is a problem when we are developing a large enterprise application because there are lots of

Read more

Springcore Constructor and setter injection to pojos

So, in our previous post we have made our basic spring project to say hello, Now in this post we gonna see how to inject values(properties) to the person pojo using spring constructor and setter based injection. Normally in any java based project Constructor based injection is happen at the time of object creation and setter injection happen with java beans by calling methods and then we give properties. But, in spring project what we do is we specify the beans(pojo) properties in beans.xml and the beans are instantiated by spring container with those values. Now we have a pojo

Read more