troubleshooting Question

autowire bean in junit is possible in spring

Avatar of gudii9
gudii9Flag for United States of America asked on
Java EEJSPJava
2 Comments1 Solution701 ViewsLast Modified:
Hi,

@Test
@Autowired
StudenDao studentDao;
public void saveStudentAndCoursewithBOClass() throws Exception{
DataSend datasend = new DataSend();
Student student= new Student();
student.setEmail("new@new2223.com");
student.setFirstName("new user firstname2223");
student.setLastName("new user lastname2223");      

Course pr = new Course();
String courseName="history";
pr.setCourseName(courseName);
courseDao.save(pr);

dataFeed.saveStudentAndCourse(student, courseName);



As above junit 4 test case method when i auto wire

@Autowired
StudenDao studentDao;

Eclipse is complaining i cannot do it. Where as same auto wiring i was able to do in regular java class. Does junit test case do not allow to auto-wire the bean using annotations?

please advice
ASKER CERTIFIED SOLUTION
mccarl
IT Business Systems Analyst / Software Developer
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros