Skip to main content

Posts

12. Injecting Values from Properties File

ok this post will be last potst abaut dependency injection in spring. ok let's start with implementasion step as usual i post : Create Properties File Load Properties File in Spring Config file Reference values from properties file 1.create properties file   2. Load properties file in spring config file 3. Reference values from properties file 4. run your app confused ? or get some error? please feel free to ask me... or you can clone this project from here .
Recent posts

11. Injecting Literal Value

in this post i will explain how to inject some value to a class / service. implementasion step : Create Setter method in your class for injection Configure the injection in Spring Config File 1. Create property with getter and setter   2. Cofigure your spring config file 3. call from your app 4. result will like this Confused ? you can clone in my repository here .

10. Spring Dependency Injection - Setter Injection

Implementasion Step : Create setter method(s) in your class for injection Configure the dependency injection in Spring config file ok lets start : 1. Create class that will inject with setter method 2. Configure your Spring Bean  3. Calling from your App 4. Run your App confused ? you can clone this project repo here

9. Spring Dependency Injection - Contructor Injection

as i say in prevous post. there are many method to inject dependency in spring. one of which is Constructor injection. in this post i will explain how to use it. ok!. there are 3 step to do this method : Define the dependency interface and class Create a constructor in your class for injection Configure the dependency Injection in Spring config file 1. create interface and implement class note : i put each class in different package interface class implements class 2. Create a constructor in your class for injection add method to interface to dependency injection implements dependency injection method from interface 3. Configure the dependency Injection in Spring config file config your spring config file call from your application and output will like this my structure package project ok, we have done in one check point. if you get confused you can clone this project in my git hub repo

8. Spring Dependency Injection - Intro

picture take from google dependency injection is a method, the continuation of the concept of inversion of control part of the SOLID design principle. the purpose of dependency injection is to release the dependence of a service or data access on a model.   for example we make a house from the beginning. when the house left the door part, would the kit make a door from the start or would we buy the door ready from the store? of course it's better for us to buy the finished one. Now, the process of making this house is analogous to a service, then to import the finished door, we use the dependency injector. so, how is dependency injection in spring framework ? please see picture below. i'm using example from previous blog post. in spring frame work you can use configuration to inject your model to your service or factory. we will practice more detail in next post. this factory called Spring Container. this primary function is  create and...

7. Configure your Spring Beans

Spring Beans is a Configuration File of your Beans and dependency in your Spring Project. there many Style of Spring Beans usage. but at least there 2 way : XML Configuration File, this way is the first way that used this method is the first method used during the first Spring release.  Class Configuration File. this is modern way. you can use java class file to save your spring bean configuration. ok inthis post i will practice XML Configuration file you can donwload from my git hub Here . download and paste it in root of src folder in your spring project.  then register your class to the spring bean create another java main class then this is how spring work .... i put my xml configuration inside folder "configFile". run this app and you will get this.

6. Spring Development Process

 Configure your spring Beans Create Spring Container Retrive Beans from Spring Container