@Test @Transactional public void saveTest() { User user = new User(); user.setName("Adam"); user.setAge(19); user.setPwd("123456"); userRepository.save(user); System.out.println("userId:" + user.getId()); Assert.assertTrue(user.getId()>0); }
@RequestMapping("/save") public boolean save() { boolean result = false; User user = new User(); user.setName("Adam"); user.setAge(19); user.setCtime(new Date().getTime()); user.setPwd("123456"); userRepository.save(user); result = user.getId() > 0; System.out.println("userId:" + user.getId()); return result; }
UserController { @RequestMapping("/save") public boolean save() { boolean result = false; User user = new User(); user.setName("Adam"); user.setAge(19); user.setCtime(new Date().getTime()); user.setPwd("123456"); userRepository.save(user); result = user.getId() > 0; System.out.println("userId:" + user.getId()); return result; } }
UserController { @RequestMapping("/save") public boolean save() { boolean result = false; User user = new User(); user.setName("Adam"); user.setAge(19); user.setCtime(new Date().getTime()); user.setPwd("123456"); userRepository.save(user); result = user.getId() > 0; System.out.println("userId:" + user.getId()); return result; }  }
UserController { @RequestMapping("/save") public boolean save() { boolean result = false; User user = new User(); user.setName("Adam"); user.setAge(19); user.setCtime(new Date().getTime()); user.setPwd("123456"); userRepository.save(user); result = user.getId() > 0; System.out.println("userId:" + user.getId()); return result; }  @RequestMapping("/") ModelAndView index(); @RequestMapping("/save") boolean save(); }
UserController { @RequestMapping("/save") public boolean save() { boolean result = false; User user = new User(); user.setName("Adam"); user.setAge(19); user.setCtime(new Date().getTime()); user.setPwd("123456"); userRepository.save(user); result = user.getId() > 0; System.out.println("userId:" + user.getId()); return result; }  @RequestMapping("/") ModelAndView index(); @RequestMapping("/save") boolean save();  }