我有以下JPA存储库:
public interface ProductRepositoryJPA extends CrudRepository<Product,String>,
PagingAndSortingRepository<Product,String> {
@Override
@EntityGraph(value="EVERYTHING", type= EntityGraph.EntityGraphType.FETCH)
Product findOne(String id);
}
如果我尝试使用spring-boot 2.0.0.M4编译,我会遇到以下错误:
ProductRepositoryJPA.java:[21,5] method does not override or implement a method from a supertype
如果我使用Spring Boot 1.5.6.RELEASE,代码编译得很好。
如果删除@Override注释并将Spring Boot保留在版本2.0.0.M3,它也可以正常编译。
这是Spring Boot 2.0.0.M3的依赖树:
-- maven-dependency-plugin:2.10:tree (default-cli) @ example-load ---
[INFO] com.example.product-load:jar:1.0-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.0.0.M4:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.0.0.M4:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.0.M4:compile
[INFO] | \- org.springframework:spring-core:jar:5.0.0.RC4:compile
[INFO] | \- org.springframework:spring-jcl:jar:5.0.0.RC4:compile
[INFO] +- org.springframework.boot:spring-boot-starter-log4j:jar:1.2.8.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.0.M4:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.0.0.M4:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.0.M4:test
[INFO] | \- org.springframework:spring-test:jar:5.0.0.RC4:test
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.0.0.M4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:2.0.0.M4:compile
[INFO] | | \- org.springframework:spring-aop:jar:5.0.0.RC4:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.0.M4:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:5.0.0.RC4:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:2.0.0.RC3:compile
[INFO] | | +- org.springframework:spring-orm:jar:5.0.0.RC4:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.0.0.RC4:compile
[INFO] | \- org.springframework:spring-aspects:jar:5.0.0.RC4:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-elasticsearch:jar:2.0.0.M4:compile
[INFO] \- org.springframework.data:spring-data-elasticsearch:jar:3.0.0.RC3:compile
[INFO] +- org.springframework:spring-context:jar:5.0.0.RC4:compile
[INFO] | \- org.springframework:spring-expression:jar:5.0.0.RC4:compile
[INFO] +- org.springframework:spring-tx:jar:5.0.0.RC4:compile
[INFO] \- org.springframework.data:spring-data-commons:jar:2.0.0.RC3:compile
和Spring-Boot的依赖树1.5.6.RELEASE:
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.5.6.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:1.5.6.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.6.RELEASE:compile
[INFO] | \- org.springframework:spring-core:jar:4.3.10.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-log4j:jar:1.2.8.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.6.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.6.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.6.RELEASE:test
[INFO] | \- org.springframework:spring-test:jar:4.3.10.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.6.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.6.RELEASE:compile
[INFO] | | \- org.springframework:spring-aop:jar:4.3.10.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.6.RELEASE:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.10.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.11.6.RELEASE:compile
[INFO] | | +- org.springframework:spring-orm:jar:4.3.10.RELEASE:compile
[INFO] | | \- org.springframework:spring-beans:jar:4.3.10.RELEASE:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.10.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-elasticsearch:jar:1.5.6.RELEASE:compile
[INFO] \- org.springframework.data:spring-data-elasticsearch:jar:3.0.0.RC3:compile
[INFO] +- org.springframework:spring-context:jar:4.3.10.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.3.10.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.3.10.RELEASE:compile
[INFO] \- org.springframework.data:spring-data-commons:jar:1.13.6.RELEASE:compile
谢谢!
答案 0 :(得分:0)
在注释掉我的“覆盖”方法之后,允许使用Spring-Boot-2.0.0.M4编译构建 - 我意识到spring-data-commons 2.0.0中不再支持findOne(T id) 。看起来它已被findById(T id)方法取代。