{"id":1624,"date":"2025-04-22T13:59:04","date_gmt":"2025-04-22T04:59:04","guid":{"rendered":"https:\/\/route-zero.com\/recruit\/?post_type=route&#038;p=1624"},"modified":"2025-09-22T13:59:20","modified_gmt":"2025-09-22T04:59:20","slug":"spring-boot-nullpointerexception%e5%ae%8c%e5%85%a8%e5%af%be%e7%ad%96%ef%bd%9c3%e5%a4%a7%e5%8e%9f%e5%9b%a0%e3%81%a8%e5%ae%9f%e8%a3%85%e4%be%8b%e3%81%be%e3%81%a8%e3%82%81","status":"publish","type":"route","link":"https:\/\/route-zero.com\/recruit\/route\/1624\/","title":{"rendered":"Spring Boot NullPointerException\u5b8c\u5168\u5bfe\u7b56\uff5c3\u5927\u539f\u56e0\u3068\u5b9f\u88c5\u4f8b\u307e\u3068\u3081"},"content":{"rendered":"<div>\n<h2>Spring Boot\u3067\u983b\u767a\u3059\u308bNullPointerException\u3001\u306a\u305c\uff1f\u3069\u3046\u9632\u3050\uff1f<\/h2>\n<hr \/>\n<h3>1. NullPointerException\u306e\u57fa\u790e\u3092\u73fe\u5834\u76ee\u7dda\u3067\u6574\u7406<\/h3>\n<p>\u300c\u3053\u3093\u306a\u30a8\u30e9\u30fc\u3001\u898b\u899a\u3048\u3042\u308a\u307e\u305b\u3093\u304b\uff1f\u300d<br \/>Java\u958b\u767a\u3067<strong>NullPointerException<\/strong>\uff08\u4ee5\u4e0bNPE\uff09\u306b\u60a9\u307e\u3055\u308c\u305f\u7d4c\u9a13\u3001\u79c1\u305f\u3061\u958b\u767a\u8005\u306a\u3089\u4e00\u5ea6\u306f\u3042\u308b\u306f\u305a\u3067\u3059\u3002<br \/>\u7126\u3063\u3066if\u6587\u3067\u201c\u5fdc\u6025\u51e6\u7f6e\u201d\u3057\u305f\u3082\u306e\u306e\u3001\u30ec\u30d3\u30e5\u30fc\u3067\u300c\u8a2d\u8a08\u7684\u306b\u9593\u9055\u3063\u3066\u3044\u308b\u300d\u3068\u6307\u6458\u3055\u308c\u3066\u3057\u307e\u3046\u2015\u2015\u305d\u3093\u306a\u30e2\u30e4\u30e2\u30e4\u3092\u4e00\u7dd2\u306b\u89e3\u6d88\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aNullPointerException<\/strong><br \/>\n      Java\u3067\u53c2\u7167\u578b\u5909\u6570\u304cnull\u306e\u307e\u307e\u30a2\u30af\u30bb\u30b9\u3055\u308c\u305f\u3068\u304d\u306b\u767a\u751f\u3059\u308b\u4f8b\u5916\u3002\u4e3b\u306b\u300c\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5b58\u5728\u3057\u306a\u3044\u72b6\u614b\u300d\u3067\u30e1\u30bd\u30c3\u30c9\u3084\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u547c\u3073\u51fa\u3059\u3068\u8d77\u304d\u307e\u3059\u3002\n    <\/p>\n<\/blockquote>\n<h4>NullPointerException\u3068\u306f\uff1f\u306a\u305c\u8d77\u304d\u308b\uff1f<\/h4>\n<p>NPE\u306f\u3001Java\u3067<strong>\u53c2\u7167\u578b\u5909\u6570\u304cnull<\/strong>\u306e\u307e\u307e\u30a2\u30af\u30bb\u30b9\u3055\u308c\u305f\u6642\u306b\u767a\u751f\u3057\u307e\u3059\u3002<br \/>\u4f8b\u3048\u3070\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre><code>String name = null;\r\nSystem.out.println(name.length()); \/\/ NPE\u767a\u751f\r\n<\/code><\/pre>\n<p>JDK14\u4ee5\u964d\u306f\u300c\u3069\u306e\u5909\u6570\u304cnull\u3060\u3063\u305f\u304b\u300d\u307e\u3067\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3067\u5206\u304b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<pre><code>Exception: Cannot invoke \"String.length()\" because \"name\" is null\r\n<\/code><\/pre>\n<p>\u539f\u56e0\u8ffd\u8de1\u306f\u5bb9\u6613\u306b\u306a\u308a\u307e\u3057\u305f\u304c\u3001\u6839\u672c\u7684\u306a<strong>\u8a2d\u8a08\u6539\u5584<\/strong>\u304c\u5fc5\u8981\u306a\u306e\u306f\u5909\u308f\u308a\u307e\u305b\u3093\u3002<\/p>\n<hr \/>\n<h3>2. \u5b9f\u52d9\u3067\u983b\u767a\u3059\u308b3\u3064\u306e\u539f\u56e0\u3068\u5bfe\u7b56<\/h3>\n<p>\u307e\u305a\u539f\u56e0\u30923\u3064\u306b\u6574\u7406\u3057\u307e\u3059\u2015\u2015<\/p>\n<h4>\u2460DB\u30a2\u30af\u30bb\u30b9\uff08JPA\uff09\u3067\u306enull<\/h4>\n<p>JPA\u306e<code>findById<\/code>\u306fOptional\u3092\u8fd4\u3057\u307e\u3059\u304c\u3001\u53e4\u3044\u30b3\u30fc\u30c9\u3067\u306fnull\u8fd4\u5374\u304c\u6b8b\u308a\u304c\u3061\u3067\u3059\u3002<br \/>\uff08JPA\u306e\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/route-zero.com\/recruit\/route\/1264\/\">\u300eJPA vs JDBC\u2502Spring Boot\u3067\u306e\u5b9f\u52d9\u7684\u306a\u4f7f\u3044\u5206\u3051\u3068\u5c0e\u5165\u5224\u65ad\u30ac\u30a4\u30c9\u300f<\/a>\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aJPA\uff08Java Persistence API\uff09<\/strong><br \/>\n      Java\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u64cd\u4f5c\u3092\u884c\u3046\u305f\u3081\u306e\u6a19\u6e96API\u3002\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u7ba1\u7406\u3084\u6c38\u7d9a\u5316\u51e6\u7406\u3092\u7c21\u5358\u306b\u8a18\u8ff0\u3067\u304d\u307e\u3059\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aOptional<\/strong><br \/>\n      \u5024\u304c\u300c\u5b58\u5728\u3059\u308b\uff0f\u3057\u306a\u3044\u300d\u3092\u660e\u793a\u7684\u306b\u6271\u3048\u308bJava\u306e\u30e9\u30c3\u30d1\u30fc\u30af\u30e9\u30b9\u3002null\u5b89\u5168\u306a\u8a2d\u8a08\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002\n    <\/p>\n<\/blockquote>\n<pre><code>User user = repository.findByName(\"taro\"); \/\/ \u5b9f\u88c5\u306b\u3088\u3063\u3066\u306fnull\r\nuser.getEmail(); \/\/ NPE\u306e\u53ef\u80fd\u6027\r\n<\/code><\/pre>\n<p><strong>\u5bfe\u7b56<\/strong>\uff1aOptional\u3067\u660e\u793a\u7684\u306b\u5b58\u5728\u78ba\u8a8d\u3092\u884c\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code>Optional&lt;User&gt; userOpt = repository.findById(1L);\r\nuserOpt.ifPresent(user -&gt; System.out.println(user.getEmail()));\r\n<\/code><\/pre>\n<h4>\u2461Spring Boot\u306eDI\u30fb\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u843d\u3068\u3057\u7a74<\/h4>\n<ul>\n<li>\n<p><code>@Autowired<\/code>\u3067Bean\u672a\u5b9a\u7fa9 \u2192 null\u6ce8\u5165<br \/>\uff08DI\u3084@Autowired\u306e\u4ed5\u7d44\u307f\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/route-zero.com\/recruit\/route\/1327\/\">\u300eSpring Boot \u306e@Autowired \u306f\u306a\u305c\u52d5\u304f\uff1fNullPointerException \u5bfe\u7b56\u304b\u3089\u5b66\u3076 DI\/IoC \u306e\u57fa\u672c\u3068\u300c\u6b63\u3057\u3044\u300d\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u7ba1\u7406\u8853\u300f<\/a>\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09<\/p>\n<\/li>\n<li>\n<p><code>@Valid<\/code>\u4ed8\u4e0e\u3067\u3082<code>BindingResult<\/code>\u672a\u6307\u5b9a\u3067\u30a8\u30e9\u30fc\u901a\u904e<\/p>\n<\/li>\n<\/ul>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aDI\uff08Dependency Injection\uff09<\/strong><br \/>\n      \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u5916\u90e8\u304b\u3089\u6ce8\u5165\u3059\u308b\u8a2d\u8a08\u624b\u6cd5\u3002Spring Boot\u3067\u306f<code>@Autowired<\/code>\u3067\u81ea\u52d5\u7684\u306bBean\u3092\u6ce8\u5165\u3067\u304d\u307e\u3059\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aBean<\/strong><br \/>\n      Spring\u3067\u7ba1\u7406\u3055\u308c\u308b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3002DI\u306e\u5bfe\u8c61\u3068\u306a\u308b\u90e8\u54c1\u3067\u3059\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a@Valid\uff0fBindingResult<\/strong><br \/>\n      <code>@Valid<\/code>\u306f\u5165\u529b\u5024\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u884c\u3046\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3002<code>BindingResult<\/code>\u306f\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u7d50\u679c\u3092\u53d7\u3051\u53d6\u308b\u305f\u3081\u306e\u5f15\u6570\u3067\u3059\u3002\n    <\/p>\n<\/blockquote>\n<p><strong>\u5bfe\u7b56<\/strong>\uff1a<\/p>\n<ul>\n<li>\n<p><code>@RequiredArgsConstructor<\/code>\u3084\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u30a4\u30f3\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3092\u5229\u7528<\/p>\n<\/li>\n<li>\n<p>Controller\u3067\u5fc5\u305a<code>BindingResult<\/code>\u3092\u5f15\u6570\u306b\u53d7\u3051\u308b<\/p>\n<\/li>\n<\/ul>\n<h4>\u2462\u30d5\u30ed\u30f3\u30c8\uff08Thymeleaf\uff09\u3068\u306e\u30c7\u30fc\u30bf\u53d7\u3051\u6e21\u3057<\/h4>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u5185\u3067null\u53c2\u7167\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u3082\u3002<br \/>\uff08Thymeleaf\u306e\u4f7f\u3044\u65b9\u3084\u30a8\u30e9\u30fc\u5bfe\u7b56\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/route-zero.com\/recruit\/route\/1471\/\">\u300eThymeleaf\u5165\u9580\u2502Spring Boot\u306710\u5206\u5b9f\u8df5\u30b5\u30f3\u30d7\u30eb5\u9078\u300f<\/a>\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aThymeleaf<\/strong><br \/>\n      Java\u306eWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u4f7f\u308f\u308c\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3002HTML\u30d5\u30a1\u30a4\u30eb\u306b\u52d5\u7684\u30c7\u30fc\u30bf\u3092\u57cb\u3081\u8fbc\u3080\u969b\u306b\u5229\u7528\u3057\u307e\u3059\u3002\n    <\/p>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aDTO\uff08Data Transfer Object\uff09<\/strong><br \/>\n      \u30c7\u30fc\u30bf\u306e\u53d7\u3051\u6e21\u3057\u5c02\u7528\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3002null\u5024\u3092\u907f\u3051\u308b\u305f\u3081\u3001\u521d\u671f\u5024\u3092\u8a2d\u5b9a\u3057\u3066\u8fd4\u3059\u8a2d\u8a08\u304c\u63a8\u5968\u3055\u308c\u307e\u3059\u3002\n    <\/p>\n<\/blockquote>\n<pre><code>&lt;p th:text=\"${user.name}\"&gt;&lt;\/p&gt;\r\n&lt;!-- user\u304cnull\u306a\u3089NPE --&gt;\r\n<\/code><\/pre>\n<p><strong>\u5bfe\u7b56<\/strong>\uff1a<\/p>\n<ul>\n<li>\n<p><code>th:if=\"${user != null}\"<\/code>\u3067\u30ac\u30fc\u30c9<\/p>\n<\/li>\n<li>\n<p>DTO\u3067\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a\u3057\u3066\u8fd4\u3059<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>3. \u5bfe\u7b56\u306e\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3\u6bd4\u8f03<\/h3>\n<h4>if\u6587\u30fb\u30ac\u30fc\u30c9\u7bc0\u306b\u3088\u308b\u57fa\u672c\u5bfe\u7b56<\/h4>\n<p>\u6700\u3082\u30b7\u30f3\u30d7\u30eb\u306a\u306e\u306fif\u6587\u3067\u306enull\u30c1\u30a7\u30c3\u30af\u3002<br \/>\u305f\u3060\u3057<strong>\u5c0f\u3055\u3044\u7bc4\u56f2\u3067\u9650\u5b9a\u4f7f\u7528<\/strong>\u3059\u3079\u304d\u3067\u3059\u3002<\/p>\n<h4>Optional\u306e\u4f7f\u3044\u65b9\u3068\u6ce8\u610f\u70b9<\/h4>\n<p>Optional\u306fJava8\u4ee5\u964d\u306e\u63a8\u5968\u624b\u6cd5\u3067\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aJava8<\/strong><br \/>\n      2014\u5e74\u306b\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u305fJava\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3002<code>Optional<\/code>\u3084\u30e9\u30e0\u30c0\u5f0f\u306a\u3069\u3001null\u5b89\u5168\u3084\u95a2\u6570\u578b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u6a5f\u80fd\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\u3002\n    <\/p>\n<\/blockquote>\n<pre><code>Optional&lt;String&gt; name = Optional.ofNullable(user.getName());\r\nSystem.out.println(name.orElse(\"\u672a\u8a2d\u5b9a\"));\r\n<\/code><\/pre>\n<p><strong>\u6ce8\u610f<\/strong>\uff1aOptional\u3092\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u6301\u305f\u305b\u308b\u306e\u306f\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f3\u3002\u623b\u308a\u5024\u306b\u9650\u5b9a\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h4>@NotNull\/@Nullable\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u6d3b\u7528<\/h4>\n<p>\u5f15\u6570\u30fb\u623b\u308a\u5024\u306b\u660e\u793a\u7684\u306b\u4ed8\u4e0e\u3059\u308b\u3068\u3001IDE\u3084\u9759\u7684\u89e3\u6790\u3067\u8b66\u544a\u53ef\u80fd\u3002<br \/>\u30ec\u30d3\u30e5\u30fc\u6642\u306b\u610f\u56f3\u3092\u5171\u6709\u3067\u304d\u308b\u5229\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1a@NotNull\uff0f@Nullable<\/strong><br \/>\n      \u5909\u6570\u3084\u5f15\u6570\u304c\u300cnull\u4e0d\u53ef\uff0fnull\u8a31\u5bb9\u300d\u3067\u3042\u308b\u3053\u3068\u3092\u660e\u793a\u3059\u308b\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3002IDE\u3084\u9759\u7684\u89e3\u6790\u30c4\u30fc\u30eb\u3067\u8b66\u544a\u3092\u51fa\u305b\u307e\u3059\u3002\n    <\/p>\n<\/blockquote>\n<h4>\u7a7a\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\uff0f\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8fd4\u3059\u8a2d\u8a08<\/h4>\n<p>\u300cnull\u3092\u8fd4\u3059\u300d\u3088\u308a\u300c\u7a7a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8fd4\u3059\u300d\u65b9\u304c\u5b89\u5168\u3067\u3059\u3002<br \/>\uff08Spring Boot\u3067\u306eList\u578b\u30fbMap\u578b\u306e\u9055\u3044\u3068Bean\u30af\u30e9\u30b9\u306e\u57fa\u790e\u306f<a href=\"https:\/\/route-zero.com\/recruit\/route\/1100\/\">\u300e\u3010Spring Boot\u5b9f\u8df5\u30ac\u30a4\u30c9\u3011List\u578b\u30fbMap\u578b\u306e\u9055\u3044\u3068Bean\u30af\u30e9\u30b9\u306e\u57fa\u790e\uff06\u5fdc\u7528\u300f<\/a>\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff09<\/p>\n<blockquote>\n<p>\n      <strong>\u7528\u8a9e\u89e3\u8aac\uff1aCollections.emptyList()<\/strong><br \/>\n      Java\u3067\u7a7a\u306e\u30ea\u30b9\u30c8\u3092\u8fd4\u3059\u6a19\u6e96\u30e1\u30bd\u30c3\u30c9\u3002null\u3092\u8fd4\u3059\u3088\u308a\u5b89\u5168\u3067\u3001NPE\u3092\u9632\u3052\u307e\u3059\u3002\n    <\/p>\n<\/blockquote>\n<pre><code>return list == null ? Collections.emptyList() : list;\r\n<\/code><\/pre>\n<hr \/>\n<h3>4. \u8a2d\u8a08\u601d\u60f3\u3068\u5236\u5ea6\u7684\u7406\u89e3\u3067\u30a8\u30e9\u30fc\u3092\u672a\u7136\u306b\u9632\u3050<\/h3>\n<h4>\u300cnull\u3092\u8fd4\u3055\u306a\u3044\u300dAPI\u8a2d\u8a08<\/h4>\n<ul>\n<li>\n<p>API\u5951\u7d04\u3068\u3057\u3066\u300cnull\u3092\u8fd4\u3055\u306a\u3044\u300d\u3092\u30c1\u30fc\u30e0\u3067\u5fb9\u5e95<\/p>\n<\/li>\n<li>\n<p>\u623b\u308a\u5024\u306fOptional\u304b\u7a7a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u7d71\u4e00<\/p>\n<\/li>\n<\/ul>\n<h4>\u30b3\u30fc\u30c9\u30ec\u30d3\u30e5\u30fc\u3067\u306e\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8<\/h4>\n<ul>\n<li>\n<p>\u5f15\u6570\u30fb\u623b\u308a\u5024\u306enull\u53ef\u80fd\u6027\u3092\u660e\u793a\u3057\u3066\u3044\u308b\u304b<\/p>\n<\/li>\n<li>\n<p>null\u30c1\u30a7\u30c3\u30af\u304c\u591a\u3059\u304e\u306a\u3044\u304b\uff08\u8a2d\u8a08\u306e\u5302\u3044\uff09<\/p>\n<\/li>\n<li>\n<p>Optional\u304c\u4e71\u7528\u3055\u308c\u3066\u3044\u306a\u3044\u304b<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>FAQ<\/h3>\n<ul>\n<li>\n<p>Java\u3067NullPointerException\u306f\u306a\u305c\u8d77\u304d\u308b\uff1f<br \/>\u2192 \u53c2\u7167\u578b\u5909\u6570\u304cnull\u306e\u307e\u307e\u30a2\u30af\u30bb\u30b9\u3055\u308c\u305f\u305f\u3081\u3067\u3059\u3002<\/p>\n<\/li>\n<li>\n<p>Optional\u3092\u4f7f\u3048\u3070NullPointerException\u306f\u5b8c\u5168\u306b\u9632\u3052\u308b\uff1f<br \/>\u2192 \u539f\u5247\u9632\u3052\u307e\u3059\u304c\u3001\u8a2d\u8a08\u6bb5\u968e\u3067Optional\u3092\u9069\u5207\u306b\u9069\u7528\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<\/li>\n<li>\n<p>Spring Boot\u3067@Valid\u3084BindingResult\u3092\u4f7f\u3063\u3066\u3082\u30a8\u30e9\u30fc\u304c\u901a\u308b\u306e\u306f\u306a\u305c\uff1f<br \/>\u2192 Controller\u30e1\u30bd\u30c3\u30c9\u3067BindingResult\u3092\u5f15\u6570\u306b\u53d7\u3051\u53d6\u3063\u3066\u3044\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<\/li>\n<li>\n<p>null\u30c1\u30a7\u30c3\u30af\u3092\u591a\u7528\u3059\u308b\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u5f71\u97ff\u3059\u308b\uff1f<br \/>\u2192 \u5f71\u97ff\u306f\u8efd\u5fae\u3067\u3059\u304c\u3001\u53ef\u8aad\u6027\u3084\u4fdd\u5b88\u6027\u304c\u4f4e\u4e0b\u3059\u308b\u65b9\u304c\u30ea\u30b9\u30af\u3067\u3059\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\u7d50\u8ad6\u3068\u5c0f\u3055\u306a\u884c\u52d5\u63d0\u6848<\/h3>\n<p>Spring Boot\u3067\u983b\u767a\u3059\u308bNullPointerException\u306f\u3001\u5358\u306a\u308b\u300c\u30a8\u30e9\u30fc\u89e3\u6c7a\u30c6\u30af\u30cb\u30c3\u30af\u300d\u3067\u306f\u306a\u304f\u3001<strong>\u8a2d\u8a08\u601d\u60f3\u3068\u30ec\u30d3\u30e5\u30fc\u4f53\u5236\u306e\u554f\u984c<\/strong>\u3068\u76f4\u7d50\u3057\u3066\u3044\u307e\u3059\u3002<br \/>JPA\u306e\u623b\u308a\u5024\u3001DI\u306e\u6ce8\u5165\u30df\u30b9\u3001Thymeleaf\u306enull\u53c2\u7167\u306a\u3069\u3001\u73fe\u5834\u3067\u518d\u73fe\u6027\u306e\u9ad8\u3044\u4e8b\u4f8b\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u7b2c\u4e00\u6b69\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u4e0a\u3067\u3001Optional\u3084\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3001\u9759\u7684\u89e3\u6790\u30c4\u30fc\u30eb\u3092\u6d3b\u7528\u3057\u3001\u300cnull\u3092\u8fd4\u3055\u306a\u3044\u8a2d\u8a08\u300d\u3092\u5fb9\u5e95\u3059\u308b\u3053\u3068\u3067\u3001\u518d\u767a\u9632\u6b62\u3068\u30b3\u30fc\u30c9\u54c1\u8cea\u306e\u5411\u4e0a\u3092\u4e21\u7acb\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30da\u3057\u3066\u3001\u307e\u305a\u306f\u52d5\u304b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<hr \/>\n<\/div>\n","protected":false},"featured_media":1625,"template":"","_links":{"self":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route\/1624"}],"collection":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route"}],"about":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/types\/route"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media\/1625"}],"wp:attachment":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media?parent=1624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}