This commit is contained in:
trang
2018-03-10 22:57:32 +08:00
parent fa007deee4
commit 16b7133b85
2 changed files with 2 additions and 3 deletions
@@ -22,7 +22,7 @@ public class CityController {
@GetMapping("/get/{id}")
public City get(@PathVariable Long id) {
return cityRepository.getOne(id);
return cityRepository.findById(id).orElse(null);
}
}
@@ -5,7 +5,6 @@ import org.junit.Assert;
import org.junit.Test;
import java.util.List;
import java.util.Optional;
/**
* MyBatis 测试
@@ -16,7 +15,7 @@ public class JpaTests extends BaseTest {
@Test
public void testOne() {
Optional.ofNullable(cityRepository.getOne(1L))
cityRepository.findById(1L)
.ifPresent(gson::toJson);
}