Maven搭建MyEclipse10+Struts2.1+Spring3.3+Hibernate3.3全注解(19)
发布时间:2021-06-05
发布时间:2021-06-05
Maven搭建MyEclipse10+Struts2.1+Spring3.3+Hibernate3.3全注解框架
package org.inscribe.farsighted.service.impl;
import javax.annotation.Resource;
import org.inscribe.farsighted.model.Student; import org.inscribe.farsighted.model.StudentDAO; import org.inscribe.farsighted.service.StudentService; import org.springframework.stereotype.Service;
@Service
public class StudentServiceImpl implements StudentService { @Resource private StudentDAO studentDAO; @Override public Student findById(Integer id) { // TODO Auto-generated method stub return studentDAO.findById(id); } }
4. 添加测试类
package org.inscribe.farsighted;
import org.inscribe.farsighted.model.Student;
import org.inscribe.farsighted.service.StudentService; import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test { public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext( "applicationContext.xml"); StudentService service = (StudentService) context.getBean("studentServiceImpl"); Student s=service.findById(1); System.out.println(s.getName()); } }
5. WEB-INF下新建Folder
包结构如下
上一篇:音视频即时通讯发展走势