我在我的项目中使用Spring 5.直到今天还有可用的方法CrudRepository#findOne.
但下载最新快照后,它突然消失了!有没有提到该方法现在不可用?
我的依赖列表:
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-validation'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
runtime 'org.springframework.boot:spring-boot-devtools'
runtime 'com.h2database:h2:1.4.194'
compile 'org.projectlombok:lombok:1.16.14'
compile 'org.modelmapper:modelmapper:0.7.5'
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'org.codehaus.groovy:groovy-all:2.4.10'
testCompile 'cglib:cglib:3.2.5'
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
}
Run Code Online (Sandbox Code Playgroud)
更新:
似乎这个方法已被替换 CrudRepository#findById
我在argument mismatch; Long cannot be converted to Example<S>下面的代码中收到了 findOne 调用:
public Optional<AuditEvent> find(Long id) {
return Optional.ofNullable(persistenceAuditEventRepository.findOne(id))
.map(auditEventConverter::convertToAuditEvent);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码正在转换为 Spring 5 和 Spring Boot 2。它在原始 Spring 4 和 Spring Boot 1 应用程序中运行良好。
任何想法我需要将上述代码转换为什么?