这段代码我很有趣。但是数据没有保存,但你好打印请指导我。
@Service
public class TestService {
@Autowired
TestRepository testRepo;
final static Logger log = Logger.getLogger(TestService.class);
@PostConstruct
public void init() {
new Thread() {
public void run() {
try {
while (true) {
process();
Thread.sleep(10000);
}
} catch (Exception exception) {
log.info("Exception while starting schedular :" + exception);
}
}
}.start();
}
@Transactional
public void process() {
Test t=new Test();
t.id=null;
t.name="Lokesh";
testRepo.save(t);
log.info("hello");
}
}
问题是Lokesh没有为表测试保存....