Skip to content

@EnableJpaRepositories#excludeFilters affects @EnableJdbcRepositories #19339

@dimone-kun

Description

@dimone-kun

We have Spring Data JPA and Spring Data JDBC enabled in one project. JPA repositories are located in com.example.demo.repository package and JDBC in com.example.demo.repository.jdbc package. We define next config:

@Configuration
@EnableJpaRepositories(
        basePackages = "com.example.demo.repository",
        excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.example.demo.repository.jdbc.*")
)
@EnableJdbcRepositories(basePackages = "com.example.demo.repository.jdbc")
public class RepositoriesConfiguration {

}

Now, if we start our application, we'll got this exception:

2019-12-10 17:10:12.510  WARN 14987 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'runner' defined in file [/home/<...>/exclude-filters-conflict-demo/build/classes/java/main/com/example/demo/Runner.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.demo.repository.jdbc.DemoJdbcRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

***************************
APPLICATION FAILED TO START
***************************

Description:
Parameter 1 of constructor in com.example.demo.Runner required a bean of type 'com.example.demo.repository.jdbc.DemoJdbcRepository' that could not be found.

Action:
Consider defining a bean of type 'com.example.demo.repository.jdbc.DemoJdbcRepository' in your configuration.

Spring Boot 2.2.1 - 2.2.2.

2.2.0 works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions