错误1:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'email.tianlangstudio.aliyun.com.portal.repo.IAppRepo' 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=appRepo)}

at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1695)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1253)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)

at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)

... 42 more

错误2:

Caused by: java.lang.IllegalArgumentException: Not a managed type: class email.tianlangstudio.aliyun.com.portal.model.App

at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:582)

at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:85)

at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:74)

at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66)

at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:211)

at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:161)

at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:144)

at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:69)

at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:312)

at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:297)

at org.springframework.data.util.Lazy.getNullable(Lazy.java:212)

*/

 

错误1是因为:Repositories扫描包配置错误

@Configuration

@EnableJpaRepositories(value = "email.tianlangstudio.aliyun.com.email.analysis",

        entityManagerFactoryRef = "masterEntityManagerFactory",

        transactionManagerRef = "masterTransactionManager")

 

错误2是因为EntityManagerFactory里的model包名忘记修改,应该修改为model所在包

@Bean(name = "masterEntityManagerFactory")

@Primary

public EntityManagerFactory masterEntityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

    factory.setJpaVendorAdapter(vendorAdapter);

    factory.setPackagesToScan("email.tianlangstudio.aliyun.com.email.analysis");

    factory.setDataSource(masterDataSource);//数据源

    factory.setJpaPropertyMap(jpaProperties.getProperties());

    factory.afterPropertiesSet();//在完成了其它所有相关的配置加载以及属性设置后,才初始化

    return factory.getObject();

}