创建对应的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();
}
}