spring boot service接口问题

报错: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个回答

public interface JpaRepository

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

public interface JpaRepository

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

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!