有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java NoSuchBean定义异常:没有“org”类型的合格bean。springframework。靴子奥姆。jpa。EntityManagerFactoryBuilder'

我正在用java编写一个lambda应用程序。一旦收到触发,它就会失败。 我的应用程序正在调用aurora数据库。 我得到了一份工作

我得到以下错误:

Error creating bean with name 'webNotifyEntityManager' defined in com.expedia.www.eps.jobs.air.offline.cancel.sync.config.AppConfig: Unsatisfied dependency expressed through method 'webNotifyEntityManager' parameter 0; nested exception is org.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:
{}
: org.springframework.beans.factory.UnsatisfiedDependencyException
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webNotifyEntityManager' defined in com.expedia.www.eps.jobs.air.offline.cancel.sync.config.AppConfig: Unsatisfied dependency expressed through method 'webNotifyEntityManager' parameter 0; nested exception is org.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:
{}

at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at -------

at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1491)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1102)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 19 more

这是我的AppConfig。java类。 请找出下面几行。 我尝试了太多步骤,但仍然无法解决

package com.expedia.www.eps.jobs.air.offline.cancel.sync.config;

import com.expedia.www.eps.jobs.air.offline.cancel.sync.Lambda;
import com.expedia.www.eps.jobs.air.offline.cancel.sync.common.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = Constants.WEBNOTIFY_REPOSITORIES,
        entityManagerFactoryRef = "webNotifyEntityManager", transactionManagerRef = "webNotifyTransactionManager")
public class AppConfig {

    @Bean
    public Properties properties() throws Exception {
        final LambdaConfigReader lambdaConfigReader =
                new LambdaConfigReader(Lambda.class.getClassLoader());
        return lambdaConfigReader.getLambdaProperties();
    }

    @Bean(name = "webNotifyDataSource")
    @Autowired
    public DataSource webnotifyDataSource(Properties properties) {
        final DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName(properties.getProperty("database.webnotify.hibernate.driver"));
        dataSource.setUrl(properties.getProperty("database.webnotify.url"));
        dataSource.setUsername(properties.getProperty("database.webnotify.username"));
        dataSource.setPassword(properties.getProperty("database.webnotify.password"));
        return dataSource;
    }

    @Bean(name = "webNotifyEntityManager")
    @Autowired
    public LocalContainerEntityManagerFactoryBean webNotifyEntityManager(EntityManagerFactoryBuilder builder,
                                                                         @Qualifier("webNotifyDataSource")
                                                                                 DataSource dataSource, Properties properties) {
        return builder.dataSource(dataSource)
                .packages(Constants.WEBNOTIFY_REPOSITORIES)
                .properties(addProperties(properties))
                .persistenceUnit(Constants.WEBNOTIFY)
                .build();
    }

    public Map<String, Object> addProperties(Properties property) {
        final HashMap<String, Object> properties = new HashMap<>();
        properties.put(Constants.HIBERNATE_DIALECT, property.getProperty("database.hibernate.dialect"));
        return properties;
    }

    @Bean(name = "webNotifyTransactionManager")
    @Autowired
    public PlatformTransactionManager webNotifyTransactionManager(
            @Qualifier("webNotifyEntityManager") EntityManagerFactory
                    webNotifyEntityManager) {
        return new JpaTransactionManager(webNotifyEntityManager);
    }
}

我的pom。是有

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.13.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.2.13.Final</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
            <version>1.5.19.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>1.5.19.RELEASE</version>
        </dependency>

我在pom文件中添加了上述罐子


共 (0) 个答案