Sql DAO和多个数据库不';我不能在春天和科特林一起工作

Sql DAO和多个数据库不';我不能在春天和科特林一起工作,sql,spring-boot,kotlin,jpa,dao,Sql,Spring Boot,Kotlin,Jpa,Dao,我正在和科特林学习春季(靴子)。 我设法用JPA存储库设置了一个工作的Spring应用程序 interface APixRepo : org.springframework.data.repository.Repository<APix, EroPixKulcs> { @Query( value="select * from felhaszn" , nativeQuery = true ) fun sokasag(): It

我正在和科特林学习春季(靴子)。 我设法用JPA存储库设置了一个工作的Spring应用程序

interface APixRepo : org.springframework.data.repository.Repository<APix, EroPixKulcs>
{
  @Query( value="select * from felhaszn"
        , nativeQuery = true
        )
  fun sokasag(): Iterable<APix>
}
其中APix是我的实体类。以及另外两个类似的实体、回购协议和控制器。
(本地SQL对我来说很重要,这是我最擅长的。)
由于这三个实体位于三个不同的数据库中,我不得不使用所描述的XxxDataSourceConfiguration魔法(Xxx=APix和另外两个)。
它仍然有效

现在我意识到repo方法对我不好,因为我的SQL必须是动态的,并且您只能在@Query()中编写常量SQL。 因此,我根据以下内容将回购协议更改为DAO:

我试过:

class AKontroller(@org.springframework.beans.factory.annotation.Qualifier("apixEntityManager") private val dao: APixRepo)
class APixRepoImpl constructor(@PersistenceContext @org.springframework.beans.factory.annotation.Qualifier("apixEntityManager") var em: EntityManager)
现在是错误:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'AKontroller' defined in file [/home/laca/spring/kotlin/zz/sokdb/build/classes/kotlin/main/com/zz/sokdb/AKontroller.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.zz.sokdb.apix.APixRepo' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier("apixEntityManager")}
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) ~[spring-beans-5.2.10.RELEASE.jar:5.2.10.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:227) ~[spring-beans-5.2.10.RELEASE.jar:5.2.10.RELEASE]
        at...
        at...
        at...
***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in com.zz.sokdb.AKontroller required a single bean, but 3 were found:
        - apixEntityManager: defined by method 'apixEntityManager' in class path resource [com/zz/sokdb/apix/APixDataSourceConfiguration.class]
        - eroEntityManager: defined by method 'eroEntityManager' in class path resource [com/zz/sokdb/ero/EroDataSourceConfiguration.class]
        - smpixEntityManager: defined by method 'smpixEntityManager' in class path resource [com/zz/sokdb/smpix/SMPixDataSourceConfiguration.class]


Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
我试过:

class AKontroller(@org.springframework.beans.factory.annotation.Qualifier("apixEntityManager") private val dao: APixRepo)
class APixRepoImpl constructor(@PersistenceContext @org.springframework.beans.factory.annotation.Qualifier("apixEntityManager") var em: EntityManager)
现在是错误:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'AKontroller' defined in file [/home/laca/spring/kotlin/zz/sokdb/build/classes/kotlin/main/com/zz/sokdb/AKontroller.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.zz.sokdb.apix.APixRepo' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier("apixEntityManager")}
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) ~[spring-beans-5.2.10.RELEASE.jar:5.2.10.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:227) ~[spring-beans-5.2.10.RELEASE.jar:5.2.10.RELEASE]
        at...
        at...
        at...
***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in com.zz.sokdb.AKontroller required a single bean, but 3 were found:
        - apixEntityManager: defined by method 'apixEntityManager' in class path resource [com/zz/sokdb/apix/APixDataSourceConfiguration.class]
        - eroEntityManager: defined by method 'eroEntityManager' in class path resource [com/zz/sokdb/ero/EroDataSourceConfiguration.class]
        - smpixEntityManager: defined by method 'smpixEntityManager' in class path resource [com/zz/sokdb/smpix/SMPixDataSourceConfiguration.class]


Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
当我在两个位置都尝试注释时,错误与我仅在Acontroller中尝试相同

在这一点上,我放弃了,来这里寻求帮助