我正在使用 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/