I am using Spring Data JPA 5.0.4 and am getting this error:
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...
This is my 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);
}
Here is how I scan the beans in applicationContext.xml
:
<context:annotation-config />
<context:spring-configured />
<aop:aspectj-autoproxy />
<tx:annotation-driven />
<context:component-scan base-package="com.my.service, com.my.repository" />
I had the same issue and it was because my entity has an attribute of type Map
. Just change it for HashMap
or similar.
I had the same exactly problem and I solve it setting @EntityScan(basePackages = {"com.mypackage.entity"})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With