'No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder'

while creating multiple data sources in spring boot getting "No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder"

I am new to spring boot trying to build application with multiple data sources/databases amazondb and snowflake db but ending with error while creating object for EntityManagerFactoryBuilder saying No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder

configuration class to create snowflake data source

package com.experian.ascend.prescreen.offerservice.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import javax.sql.DataSource;
@ComponentScan
@Component
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "SnowFlakeEntityManagerFactory",
        transactionManagerRef = "SnowFlakeTransactionManager",
        basePackages = { "com.experian.ascend.prescreen.offerservice.repositories.ScoreRepository" }
)
public class SnowFlakeJPASetup {
    @Autowired
    SecretManager securityManager;

    @Bean(name = "dataSource")
    public DataSource dataSource() {
        return securityManager.getDataSource();
    }
    @Bean(name = "SnowFlakeEntityManagerFactory")
    public LocalContainerEntityManagerFactoryBean
    SnowFlakeEntityManagerFactory(
            EntityManagerFactoryBuilder builder,
            @Qualifier("dataSource") DataSource dataSource
    ) {
        return
                builder
                        .dataSource(dataSource)
                        .packages("com.experian.ascend.prescreen.offerservice.model")
                        .persistenceUnit("score")
                        .build();
    }

    @Bean(name = "SnowFlakeTransactionManager")
    public PlatformTransactionManager SnowFlakeTransactionManager(
            @Qualifier("SnowFlakeEntityManagerFactory") EntityManagerFactory
                    SnowFlakeEntityManagerFactory
    ) {
        return new JpaTransactionManager(SnowFlakeEntityManagerFactory);
    }
}

log:

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.378 s <<< FAILURE! - in com.experian.ascend.prescreen.offerservice.integration.testcases.TestRunner
[ERROR] Feature: PS1 Score Service  Micro Services API Test cases  Time elapsed: 11.373 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'SnowFlakeEntityManagerFactory' defined in class path resource [com/experian/
ascend/prescreen/offerservice/configuration/SnowFlakeJPASetup.class]: Unsatisfied dependency expressed through method 'SnowFlakeEntityManagerFactory' parameter 0; nested exception is o
rg.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' available: expected at least 1
 bean which qualifies as autowire candidate. Dependency annotations: {}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder' available: expecte
d at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}


Sources

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

Source: Stack Overflow

Solution Source