SpringBoot之事務處理(K)
阿新 • • 發佈:2019-02-05
建立對應的service
JpaService.java
package cn.wuyang.springboot.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.wuyang.springboot .dao.JpaDao;
import cn.wuyang.springboot.entity.Jpa;
@Service
public class JpaService {
@Autowired
private JpaDao jpaDao;
//開啟事務
@Transactional
public List<Jpa> jpaList(){
return jpaDao.findAll();
}
}