Maven搭建MyEclipse10+Struts2.1+Spring3.3+Hibernate3.3全注解(19)

发布时间: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

包结构如下

Maven搭建MyEclipse10+Struts2.1+Spring3.3+Hibernate3.3全注解(19).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219