Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java maven在创建自定义接口CrudDao和crudepository(spring数据jpa)时编译不明确_Java_Maven_Spring Data Jpa - Fatal编程技术网

Java maven在创建自定义接口CrudDao和crudepository(spring数据jpa)时编译不明确

Java maven在创建自定义接口CrudDao和crudepository(spring数据jpa)时编译不明确,java,maven,spring-data-jpa,Java,Maven,Spring Data Jpa,我制作了一个接口CrudDao.java public interface CrudDao<T extends Entity<ID>, ID extends Serializable> { <S extends T> save (S entity); } @NoRepositoryBean public interface GenericCrudDao<T extends GenericEntity> extends CrudD

我制作了一个接口CrudDao.java

public interface CrudDao<T extends Entity<ID>, ID extends Serializable> {
    <S extends T> save (S entity);
}

@NoRepositoryBean
public interface GenericCrudDao<T extends GenericEntity> extends 
    CrudDao<T, Long>,
    JpaRespoitory<T, Long>,
    JpaSpecificationExecutor<T>,
    PagingAndSortingDao<T, Long> {

}
公共接口CrudDao{
保存(S实体);
}
@菜豆
公共接口GenericCrudDao扩展
克鲁多,
JPA政治,
JpaSpecificationExecutor,
Paging和Sortingdao{
}
那么我真正的业务dao就是扩展GenericDao。但是,当我在Eclipse中运行build时,它就不能在Maven中编译了

它将显示

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project myproject: Compilation failure: Compilation failure:
[ERROR] MemberService.java:[39,26] error: reference to save is ambiguous
[ERROR] both method <S#1>save(S#1) in CrudRepository and method <S#2>save(S#2) in CrudDao match
[ERROR] where S#1,T#1,S#2,T#2,ID are type-variables:
[ERROR] S#1 extends T#1 declared in method <S#1>save(S#1)
[ERROR] T#1 extends Object declared in interface CrudRepository
[ERROR] S#2 extends T#2 declared in method <S#2>save(S#2)
[ERROR] T#2 extends Entity<ID> declared in interface CrudDao
[ERROR] ID extends Serializable declared in interface CrudDao
[ERROR]无法在项目myproject上执行目标org.apache.maven.plugins:maven编译器插件:3.5.1:compile(默认编译):编译失败:编译失败:
[错误]MemberService.java:[39,26]错误:要保存的引用不明确
[错误]CRUDEPository中的方法保存(S#1)和CrudDao中的方法保存(S#2)都匹配
[错误]其中S#1、T#1、S#2、T#2、ID是类型变量:
[错误]S#1扩展了在方法save(S#1)中声明的T#1
[错误]T#1扩展接口CRUDEPository中声明的对象
[错误]S#2扩展了方法save(S#2)中声明的T#2
[错误]T#2扩展接口CrudDao中声明的实体
[错误]ID扩展接口CrudDao中声明的可序列化

该实体为extends GenericEntity extends实体。为什么maven编译器会含糊不清地使用CurdDao.save(实体)和CrudRespository.save(对象)。我如何更改代码,让maven编译成功?

maven只调用
javac
。Eclipse有自己的编译器。为什么要扩展所有这些接口?如果直接扩展
CrudDao
extended
paging和sortingrepository
,就不会有这样的问题。CrudDao扩展了paging和sortingdao,而不是paging和sortingrepository。@NoRepositoryBean公共接口paging和sortingdao{Long countByCondition(final t entity);List findByCondition(final T entity,final Pageable Pageable);}尝试使用命令行构建。如果您成功了,那么是Eclipse配置问题,即使只是调用
javac
。Eclipse有自己的编译器。为什么要扩展所有这些接口?如果直接扩展
CrudDao
extended
paging和sortingrepository
,就不会有这样的问题。CrudDao扩展了paging和sortingdao,而不是paging和sortingrepository。@NoRepositoryBean公共接口paging和sortingdao{Long countByCondition(final t entity);List findByCondition(final T entity,final Pageable Pageable);}尝试使用命令行构建。如果您成功了,那么这就是Eclipse配置问题