1 package com.bxw.service;
2
3 import javax.annotation.Resource;
4
5 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.beans.factory.annotation.Qualifier;
7 import org.springframework.stereotype.Service;
8
9 import com.bxw.dao.UserDao;
10 import com.bxw.dao.impl.UserDaoImpl;
11 import com.bxw.po.User;
12
13 @Service
14 public class UserService {
15 private UserDao userDao = new UserDaoImpl();
16
17 public void init() {
18 System.out.println("init...");
19 }
20
21 public UserDao getUserDao() {
22 return userDao;
23 }
24
25 @Resource(name="userDao")
26 public void setUserDao(UserDao userDao) {
27 this.userDao = userDao;
28 }
29
30 public void add(User u){
31 this.userDao.save(u);
32 }
33
34 public void destroy() {
35 System.out.println("destroy...");
36 }
37
38 }