为了降低dao层与service层的耦合性
UserController.java
package com.yiheng.demo;
import com.yiheng.service.UserService;
import com.yiheng.service.impl.UserServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class UserController {
public static void main(String[] args) {
ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext.xml");
UserService userService = (UserService) app.getBean("userService");
userService.save();
}
}
UserDaoImpl.java
package com.yiheng.dao.impl;
import com.yiheng.dao.UserDao;
public class UserDaoImpl implements UserDao {
public UserDaoImpl(){
System.out