我在下面的这段代码中有这部分内容,并且在移至新版本的spring即2.1.5 RELEASE之后,现在可以使用了 请对此提供帮助-
以前,我的Spring Boot版本为1.5.7-下面是我现在和之前的pom.xml
文件。
错误:页面类型中的方法map(Function)不适用于 参数(new Converter(){})
Pom.xml(现在):
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<guava.version>28.0-jre</guava.version>
<jwt.version>0.9.0</jwt.version>
<commons-lang.version>3.9</commons-lang.version>
<joda-time.version>2.10.2</joda-time.version>
<start-class>com.afcs</start-class>
</properties>
Pom.xml(优先级):
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<guava.version>26.0-jre</guava.version>
<jwt.version>0.9.0</jwt.version>
<commons-lang.version>3.7</commons-lang.version>
<joda-time.version>2.10</joda-time.version>
<start-class>com.afcs</start-class>
</properties>
final Page<DutyAllocationDto> dutyAllocationDto = dutyAllocationBean
.map(new Converter<DutyAllocationBean, DutyAllocationDto>() {
@Override
public DutyAllocationDto convert(DutyAllocationBean entity) {
DutyAllocationDto dto = new DutyAllocationDto();
ModelMapper modelMapper = new ModelMapper();
dto = modelMapper.map(entity, DutyAllocationDto.class);
DutyAllocation dutyAllocation = dutyAllocationFilterRepository
.findById(entity.getDutyallocationid()).get();
if (dutyAllocation != null) {
dto.setCityName(dutyAllocation.getTblDepotMaster().getCityMaster().getCityName());
}
if(dto.getRoutenumber()!=null)
{
Tblroutemaster route=tblroutemasterRepository.findByrouteNumber(Long.valueOf(dto.getRoutenumber()));
if(route!=null)
{
dto.setRouteName(route.getRouteName());
}
}
return dto;
}
});