qq_38587288
qq_38587288
采纳率100%
2018-04-22 09:08 阅读 2.0k
已采纳

spring boot service接口问题

5

报错:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'girlController': Unsatisfied dependency expressed through field 'girlRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'girlRepository': Post-processing of merged bean definition failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.PersistenceContext.synchronization()Ljavax/persistence/SynchronizationType;

GirlRepository:
import org.springframework.data.jpa.repository.JpaRepository;

public interface GirlRepository extends JpaRepository {
}

GirlController:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GirlController {

@Autowired
private GirlRepository girlRepository;

@GetMapping(value = "/girls")
public List<Girl> girlList(){
    return girlRepository.findAll();
}

}

求大神帮忙看看哪里的问题啊?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    feelcycle_07 默默悟问 2018-04-22 10:08

    public interface JpaRepository

    必须指定好T和ID才能实际初始化

    点赞 评论 复制链接分享
  • louk001 louk001 2018-04-22 10:23

    public interface JpaRepository

    必须指定好T和ID才能实际初始化

    点赞 评论 复制链接分享
  • qdboi 发抖吧小喵喵 2018-04-24 02:27

    public interface GirlRepository extends JpaRepository 要指定实体类和主键类型

    点赞 评论 复制链接分享

相关推荐