gvdm
gvdm

Reputation: 3156

Enable CrudRepository in Spring java config

I'm trying to implement Spring's repositories in my DAL. I'm following this guide.

At the third step of "1.2 Query methods" paragraph we need to activate the repository package scanning with the following XML configuration

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

  <repositories base-package="com.acme.repositories" />

</beans>

In my project I'm using only java config so this declaration is a little problematic for me. What is the right way to make things done in java conf in this case?

Thank you

Upvotes: 0

Views: 2745

Answers (1)

geoand
geoand

Reputation: 64011

You need to add the following annotation to your configuration class:

@EnableJpaRepositories("com.acme.repositories")

Upvotes: 2

Related Questions