java - Spring中具有相同名称的多个字段

标签 java spring autowired entity-bean

<分区>

我有以下内容:

public class ClaimFacadeImpl implements ClaimFacade {

    @Autowired
    private DebtRepository<Claim> debtRepository;

    @Autowired
    private DebtRepository<Fine> fineRepository;

    //other stuff

}

public interface DebtRepository <T extends Debt> {
   //nothing special
}

public class DebtRepositoryImpl <T extends Debt> implements DebtRepository <T> {
   //nothing special
}

和 2 个类。一项 claim 和一项罚款均延长了债务。 我收到错误 More than one field with type interface domain.debt.DebtRepository

我该怎么办?

最佳答案

如果您还没有升级到 Spring 4.0:

参见 http://spring.io/blog/2013/12/03/spring-framework-4-0-and-java-generics

关于java - Spring中具有相同名称的多个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26777580/

相关文章:

linux - 无法在 Linux Ubuntu 12.04 上运行 maven2

java - 直接 java.nio.ByteBuffer 与 Java Array 性能测试

java - ionic 应用程序运行时错误 - 找不到类 com.vladstirbu.cordova.plugin.utils.AssetProvider

java - 强制 Spring 在运行时使用特定的类代替另一个类

java - Spring Data JPA 查询不起作用,列不存在

java - 当 @Autowired 和 @Bean 出现在同一个类中时出现 BeanCurrentlyInCreationException

java - 如何在 spring boot 应用程序中配置 PageableHandlerMethodArgumentResolver

java - 为什么我的 Spring PropertySource 注释在编码属性上失败?

基于 Java 的配置,带参数的 Autowiring bean

java - 运行时通过条件进行依赖注入(inject)