【发布时间】:2020-02-25 13:12:12
【问题描述】:
我已经尝试解决这个问题超过几个小时,但我不能, 我基本上是在尝试进行 crud 操作,但是当我使用保存方法进行服务实现时,它会显示错误“推断类型参数‘S’的类型‘S’不在其范围内;应该扩展‘java.lang.Integer’”那么摆脱这种按摩的步骤是什么
存储库接口
package com.crudeoperation.demopro.Repo;
import com.crudeoperation.demopro.Entities.Location;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface LocationRepository extends CrudRepository<Integer, Location> {
}
定位服务
package com.crudeoperation.demopro.Services;
import com.crudeoperation.demopro.Entities.Location;
import java.util.List;
import java.util.Optional;
public interface LocationServices {
Location saveLocation(Location location );
Location UpdateLocation(Location location);
void deleteLocation(Location location);
Optional<Integer> getLocationById(int id);
List<Location> getAllLocation();
}
LocationServicesImpl
package com.crudeoperation.demopro.Services;
import com.crudeoperation.demopro.Entities.Location;
import com.crudeoperation.demopro.Repo.LocationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Optional;
public class LocationServicesImpl implements LocationServices {
@Autowired
private LocationRepository locationRepository;
@Override
public Location saveLocation(Location location) {
return locationRepository.save(location);
}
@Override
public Location UpdateLocation(Location location) {
return null;
}
@Override
public void deleteLocation(Location location) {
}
@Override
public Optional<Integer> getLocationById(int id) {
return Optional.empty();
}
@Override
public List<Location> getAllLocation() {
return null;
}
}
【问题讨论】:
标签: java spring-boot-maven-plugin