Java Spring数据JPA依赖项错误

Java Spring数据JPA依赖项错误,java,spring,hibernate,spring-boot,spring-data-jpa,Java,Spring,Hibernate,Spring Boot,Spring Data Jpa,有人能帮我找到与字符串jpa一起工作的正确的字符串引导依赖项吗? 我的问题是,当我使用下面的gradle依赖项配置时,我得到一个错误 dependencies { compile 'org.springframework.boot:spring-boot-starter-thymeleaf' compile 'org.springframework:spring-orm:4.2.4.RELEASE' compile 'org.springframework.data:spring-data-jp

有人能帮我找到与字符串jpa一起工作的正确的字符串引导依赖项吗? 我的问题是,当我使用下面的gradle依赖项配置时,我得到一个错误

dependencies {
compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
compile 'org.springframework:spring-orm:4.2.4.RELEASE'
compile 'org.springframework.data:spring-data-jpa:1.10.5.RELEASE'
compile 'org.hibernate:hibernate-core:5.0.6.Final'
compile 'org.hibernate:hibernate-entitymanager:5.0.6.Final'
compile 'org.apache.tomcat:tomcat-dbcp:8.0.30'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity4:2.1.2.RELEASE'
错误


但是当我使用下面的配置时,它运行正常,但是在我的Dao配置中使用@Query注释和JPQL时,我遇到了“AbstractStringBasedJpaQuery中的NullPointerException”问题

@Repository
public interface ExamsDao extends CrudRepository<Exams,Long>{
    @Query("select e from Exams e where e.user.id=:#{principal.id}")
    List<Exams> findAll();
}
根据规范-

您的查询应该如下所示:

@Query("select e from Exams e where e.user.id= ?#{principal.id}")
当引用传递给方法的参数时,将使用
。。但是您的方法中没有任何参数。

根据
查询示例Executor
是在
1.12
中添加的。您似乎引用了
1.9.6.RELEASE
。你应该升级到<代码> 1.121.版本或考虑去<代码> 2.0.0. M1ClassNotFoundException。可能会出现其他异常,因为其他依赖项与最新的
Spring数据版本不兼容


有时,您可以在种子项目中获得一个有效的依赖项配置,如(仅举一个例子)。否则,请调出每个lib并注意错误,或者将所有lib调到最新版本(以防您的源代码仍然使用最新的lib)

使用Spring Boot包含Spring数据的正确方法是使用
Spring Boot starter Data jpa
starter。删除spring数据和hibernate依赖项,并进行如下替换:

dependencies {
 compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
 compile 'org.springframework.boot:spring-boot-starter-data-jpa'
 compile 'org.apache.tomcat:tomcat-dbcp:8.0.30'
 compile 'org.springframework.boot:spring-boot-starter-security'
 compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity4:2.1.2.RELEASE'
}
有关更多详细信息,请参阅

@Query("select e from Exams e where e.user.id= ?#{principal.id}")
dependencies {
 compile 'org.springframework.boot:spring-boot-starter-thymeleaf'
 compile 'org.springframework.boot:spring-boot-starter-data-jpa'
 compile 'org.apache.tomcat:tomcat-dbcp:8.0.30'
 compile 'org.springframework.boot:spring-boot-starter-security'
 compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity4:2.1.2.RELEASE'
}