0

I have my custom starter. Inside it, I define a repository. How should I define it in the configuration? This is how I did the usual bean before.

@Bean
@ConditionalOnMissingBean(HelloWorldController.class)
public HelloWorldController helloWorldController() {
    return new HelloWorldController();
}

Repository:

@Repository
public interface CarRepository extends JpaRepository<Car, Long> {
}

And configuration

@Configuration
@EnableJpaRepositories
public class DomainConfiguration {
}

If you use this starter, context will not see the repository bean. Because I did not declare it in the configuration.I don't know how to declare it.

1 Answers1

0

In the configuration class, you must use the @EnableJpaRepositories and @EntityScan annotations, indicating the package in which the Repositories and Entity classes are located

@Configuration
@EnableJpaRepositories(basePackages = {"com.my.app.repository"})
@EntityScan(basePackages = {"com.my.app.entity"})
public class DomainConfiguration  {
}
IlnarMT
  • 21
  • 1