In this tutorial you will learn about how to exclude specified component in spring framework.
In this tutorial you will learn about how to exclude specified component in spring framework.In this tutorial you will learn about how to exclude specified component, if you want spring to avoid detection and inclusion into the spring container exclude those files with the @Service annotation
StudentDAO.java
package com.roseindia.student.dao;
import org.springframework.stereotype.Service;
@Service
public class StudentDAO {
@Override
public String toString() {
return " Inside StudentDAO";
}
}
StudentService .java
package com.roseindia.student.services;
import org.springframework.stereotype.Service;
import com.roseindia.student.dao.StudentDAO;
@Service
public class StudentService {
StudentDAO studentDAO;
@Override
public String toString() {
return "StudentService [studentDAO=" + studentDAO + "]";
}
}
AppMain .java
package com.roseindia.common;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.roseindia.student.services.StudentService;
public class AppMain {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "context.xml" });
StudentService stud = (StudentService) context
.getBean("studentService");
System.out.println(stud);
}
}
context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
|
| StudentService [studentDAO=null] |