'Can I define SpringDataJpa repository without <context:annotation-config/>

I would like to know why I am getting this error Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: EntityPathResolver must not be null! when I am not having <context:annotation-config/>. From my understanding the <context:annotation-config/> should only enable annotations like @Autowire, @Resource etc.

This is my application-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:context="http://www.springframework.org/schema/context"

       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/util
       http://www.springframework.org/schema/util/spring-util.xsd
       http://www.springframework.org/schema/data/jpa
       https://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">

    <import resource="data-source-context.xml"/>

<!--    <context:annotation-config/>-->

    <jpa:repositories
            base-package="com.znamenacek.repository.springdatajpa"
            entity-manager-factory-ref="emf"
            transaction-manager-ref="transactionManager"
    />

    <bean id="transactionManager"
          class="org.springframework.orm.jpa.JpaTransactionManager"
          p:entityManagerFactory-ref="emf"
    />

    <bean id="emf"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
          p:dataSource-ref="dataSource"
          p:jpaVendorAdapter-ref="jpaVendorAdapter"
          p:packagesToScan="com.znamenacek.entity"
          p:jpaProperties-ref="hibernateProperties"
    />

    <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>

    <util:properties id="hibernateProperties"
                     location="hibernate.properties"
    />

</beans>

Could you please explain me where is the problem and how can I get rid off the <context:annotation-config/>?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source