- service层代码
UserService service;
@Autowired
public void setService(UserService service) {
this.service = service;
}
@Override
public void add(User user) {
System.out.println(mapper);
Thread thread = new Thread(new MyRunnable(mapper, user));
thread.start();
}
class MyRunnable implements Runnable {
UserMapper mapper;
User user;
public MyRunnable(UserMapper mapper, User user) {
this.mapper = mapper;
this.user = user;
System.out.println(mapper);
System.out.println(user);
}
@Override
public void run() {
mapper.insert(user);
}
}
@Test
public void test1() {
User u1 = new User(1L,"A");
service.add(u1);
}
控制台输出
数据库确没数据,又不报错。