@Autowired and @Qualifier Annotations for Spring

We use @Autowired to automatically wire our bean dependencies. Example In the following example, we have autowired the home address for our student from the previous example. Spring will look for a single bean with a type that matches the type for home. If it finds this bean then it will automatically inject that bean … Continue reading @Autowired and @Qualifier Annotations for Spring

Advertisements

@Required Spring Annotation

@Required We use the @Required annotation to tell Spring that a property on a bean is required. Student.java Here we have applied the @Required annotation to the method setStudentId. student1.xml This will do nothing if we do not add the RequiredAnnotationBeanPostProcessor bean to our Spring config xml file. TestStudent1.java Now we can bring it all … Continue reading @Required Spring Annotation

Spring 3 – Injecting Values with XML Config

Overview This post demonstrates setting Spring Bean property values using an xml config file. The example demonstrates the following principles: setter injection constructor injection (by index) multiple argument injection (by name) bean injection by reference list injection (by value and by reference) aliases Example The following example is presented as a Maven Project.  The Spring … Continue reading Spring 3 – Injecting Values with XML Config

Spring 3 – Basic Example

Creating the Project Open Eclipse (Kepler) New -> Maven Project Simple Project Group Id: com.skills421.examples.spring Artifact Id: Spring3.2.6Example Finish pom.xml Person bean src/main/java com.skills421.examples.spring.model.Person ApplicationContext src/main/resources ApplicationContext.xml Main src/main/java com.skills421.examples.spring.Main Output

Spring 2.5.6 Basic Example

Creating the Project Open Eclipse (Kepler) New -> Maven Project Simple Project Group Id: com.skills421.examples.spring Artifact Id: Spring2.5.6Example Finish pom.xml Person bean src/main/java com.skills421.examples.spring.model.Person ApplicationContext src/main/resources ApplicationContext.xml Main src/main/java com.skills421.examples.spring.Main Output

Drools6.0 Basic Example

This post has been updated to the very latest Drools6.x - the new post can be found here: Drools6.x Basic Example Creating the Project Open Eclipse (Kepler) New -> Maven Project Simple Project Group Id: com.skills421.examples.drools Artifact Id: Drools6.0Example Finish pom.xml Rule Runner src/main/java com.skills421.examples.drools.controller.RuleRunner Person src/main/java com.skills421.examples.drools.model.Person Main src/main/java com.skills421.examples.drools.Main Rules src/main/resources test1.drl Output

Drools5.6 Basic Example

Creating the Project Open Eclipse (Kepler) New -> Maven Project Simple Project Group Id: com.skills421.examples.drools Artifact Id: Drools5.6Example Finish pom.xml Rule Runner src/main/java com.skills421.examples.drools.controller.RuleRunner Person src/main/java com.skills421.examples.drools.model.Person Main src/main/java com.skills421.examples.drools.Main Rules src/main/resources test1.drl Output