java - Spring Data JPA 'jpaMappingContext' 错误,IllegalStateException : Expected to be able to resolve a type but got null

标签 java spring spring-mvc spring-data spring-data-jpa

我正在使用 Spring Data JPA 5.0.4 并收到此错误:

Error creating bean with name 'myRepository': Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Expected to be able to resolve a type but got null! This usually stems from types implementing raw Map or Collection interfaces! at...

这是我的 myRepository bean:

@Repository
public interface MyRepository extends CrudRepository<MyEvent, Long> {

    List<MyEvent> findAll();

    MyEvent save(MyEvent persisted);

    Optional<MyEvent> findById(Long id);

    Optional<MyEvent> findByMyEventId(long id);

    List<MyEvent> findByCurrentActivityTypeCd(BigDecimal id);

    List<MyEvent> findByCity(String city);
}

下面是我如何扫描 applicationContext.xml 中的 bean:

   <context:annotation-config />
   <context:spring-configured />
   <aop:aspectj-autoproxy />

   <tx:annotation-driven />

   <context:component-scan base-package="com.my.service, com.my.repository" />

最佳答案

我有同样的问题,这是因为我的实体有一个 Map 类型的属性。只需将其更改为 HashMap 或类似的。

关于java - Spring Data JPA 'jpaMappingContext' 错误,IllegalStateException : Expected to be able to resolve a type but got null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50394856/

相关文章:

使用 writeBytes 的 Java 客户端套接字

java - 为什么歧义发生在多重继承中而不是接口(interface)中

java - 如何实现 SharedPreferences?

mysql - LEFT JOIN 与 ON - Spring 中的 JPA 存储库

java - 将 HttpServletRequest 获取到 Spring ResponseEntityExceptionHandler 中

security - 人们为 Web 应用程序的登录安全做了哪些工作?

spring-mvc - 我应该在 uml 类图中描述 Web 应用程序的哪一层(仅限模型或模型 + Controller )

java - 使用 Map 的方法 "getOrDefault()"

java - 如何使用 ExtractorMediaSource.Factory 在 ExoPlayer 中设置自定义 header ?

java - 获取 Jasig Cas 客户端验证错误。 PKIX 路径构建失败