0

Is it possible to have Spring Data JDBC and Spring Data hibernate in one project ?

@SpringBootApplication
@ComponentScan(basePackages = {"com.meteor", "com.test"})
//@EnableMeteorTransactionManagement
@EnableFeignClients(basePackages = "com.meteor.keycloak.utils")
@EnableJdbcRepositories(basePackages = {"com.test.coral"})
@EnableJpaRepositories(basePackages = {"com.meteor.coral"}, repositoryBaseClass = MeteorAdapterRepositoryImpl.class)

It seems that the beans are not being seen by the application context.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.test.coral.resources.useradministration.domain.AppUserRepo' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value="appUserRepo")}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1714)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1270)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1224)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
    ... 29 more

Thanks

grassbl8d
  • 2,089
  • 4
  • 24
  • 34
  • I also saw these. Spring Data JDBC - Could not safely identify store assignment for repository candidate interface com.sxi.coral.resources.useradministration.domain.AppUserRepo. If you want this repository to be a JDBC repository, consider annotating your entities with one of these annotations: org.springframework.data.relational.core.mapping.Table. – grassbl8d Nov 12 '20 at 07:54

1 Answers1

2

The issue is the table annotation mapping.

@Data
@Entity
@Table(name = "m_appuser", uniqueConstraints = @UniqueConstraint(columnNames = { "username" }, name = "username_org"))
@org.springframework.data.relational.core.mapping.Table

I needed to add the Spring Data JDBC Table annotation for it to work.

grassbl8d
  • 2,089
  • 4
  • 24
  • 34