{"id":254,"date":"2019-08-19T10:18:34","date_gmt":"2019-08-19T01:18:34","guid":{"rendered":"http:\/\/2019se3.satoshis.jp\/?p=254"},"modified":"2019-08-19T12:29:56","modified_gmt":"2019-08-19T03:29:56","slug":"8%e6%9c%8819%e6%97%a5","status":"publish","type":"post","link":"https:\/\/2019se3.satoshis.jp\/?p=254","title":{"rendered":"8\u670819\u65e5"},"content":{"rendered":"<h3>Spring Boot\u306e\u5fa9\u7fd2<\/h3>\n<p>\u7c21\u5358\u306aWeb\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b\u3002<\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d: bookshelf<br \/>\n\u30d1\u30c3\u30b1\u30fc\u30b8\u540d: jp.abc<\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3068\u3001pom.xml\u5185\u3067\u306eSpringBoot\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c2.1.7\u306b\u306a\u3063\u3066\u3044\u308b\u304c\u3001\u305d\u306e\u307e\u307e\u3067\u306f\u30d3\u30eb\u30c9\u30a8\u30e9\u30fc\u306b\u306a\u308b\u306e\u3067\u3001\u3053\u308c\u30922.1.4\u306b\u5909\u66f4\u3059\u308b\u3002<\/p>\n<p>Bookshelf\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u3068Book\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>Bookshelf\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306f name \u306e\u307f\u3002<\/p>\n<p>Book\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306f title \u3068 author \u306e\u4e8c\u3064\u3002<\/p>\n<p>\u4f5c\u6210\u3059\u308b\u30da\u30fc\u30b8<\/p>\n<ul>\n<li>\u30c8\u30c3\u30d7\u30da\u30fc\u30b8 http:\/\/localhost:8080\/<\/li>\n<li>Bookshelf\u30da\u30fc\u30b8 http:\/\/localhost:8080\/bookshelf<\/li>\n<li>Book\u30da\u30fc\u30b8 http:\/\/localhost:8080\/book<\/li>\n<\/ul>\n<p>\u30d3\u30eb\u30c9\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u4eba\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u306e\u3000<br \/>\n\u3000\u6388\u696d\u8cc7\u6599\u30fbOC\u8cc7\u6599\\\u6fa4\u7530\\2019_SpringBOOT\\repository<br \/>\n\u3092\u3001<br \/>\n\u3000\u30e6\u30fc\u30b6\u30fc\\.m2<br \/>\n\u306b\u4e0a\u66f8\u304d\u3057\u3066\u307f\u308b\u3002<\/p>\n<p><strong>pom.xml\u306e\u5909\u66f4<\/strong><br \/>\n<a href=\"http:\/\/2019se3.satoshis.jp\/?p=209\">7\u67082\u65e5<\/a>\u306e\u30da\u30fc\u30b8\u3092\u53c2\u7167\u3057\u3066\u3001pom.xml\u3092\u5909\u66f4\u3059\u308b\u3002<br \/>\nThymeleaf\u3068JPA\u3068HSQLDB\u306e\u4f9d\u5b58\u95a2\u4fc2\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<p><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u7528\u610f<\/strong><br \/>\n\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u306b\u4f5c\u6210\u3057\u305fhsqldb.bat\u3092\u7de8\u96c6\u3057\u3066 bookshelf \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u7528\u610f\u3059\u308b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd C:\\pleiades\\hsqldb-2.4.1\\hsqldb\\lib\r\njava -cp hsqldb.jar org.hsqldb.Server --database.0 db\/mydata --dbname.0 mydata --database.1 db\/bookshelf --dbname.1 bookshelf\r\n<\/pre>\n<p><strong>\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3059\u308b<\/strong><\/p>\n<p>src\/main\/resources\/<br \/>\n\u2514templates<br \/>\n\u3000\u2514index.html<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html xmlns:th=&quot;http:\/\/www.thymeleaf.org&quot;&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=&quot;UTF-8&quot;&gt;\r\n&lt;title&gt;top page&lt;\/title&gt;\r\n&lt;style type=&quot;text\/css&quot;&gt;\r\nh1 {\r\n  font-size: 18pt;\r\n  font-weight: bold;\r\n  color: gray;\r\n}\r\nbody {\r\n  font-size: 13pt;\r\n  color: gray;\r\n  margin: 5px 25px;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;top page&lt;\/h1&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3092\u4f5c\u6210\u3059\u308b<\/strong><\/p>\n<p>src\/main\/java\/<br \/>\n\u2514jp.abc<br \/>\n\u3000\u2514IndexController.java<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.abc;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\nimport org.springframework.web.bind.annotation.RequestMethod;\r\nimport org.springframework.web.servlet.ModelAndView;\r\n\r\n@Controller\r\npublic class IndexController {\r\n\t@RequestMapping(value = &quot;\/&quot;, method = RequestMethod.GET)\r\n\tpublic ModelAndView index(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;index&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p><strong>Bookshelf(\u672c\u68da)\u3092\u4f5c\u6210\u3059\u308b<\/strong><\/p>\n<p>HTML\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>src\/main\/resources\/<br \/>\n\u2514templates<br \/>\n\u3000\u2514bookshelf.html<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html xmlns:th=&quot;http:\/\/www.thymeleaf.org&quot;&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=&quot;UTF-8&quot;&gt;\r\n&lt;title&gt;Bookshelf&lt;\/title&gt;\r\n&lt;style type=&quot;text\/css&quot;&gt;\r\nh1 {\r\n  font-size: 18pt;\r\n  font-weight: bold;\r\n  color: gray;\r\n}\r\nbody {\r\n  font-size: 13pt;\r\n  color: gray;\r\n  margin: 5px 25px;\r\n}\r\ntr {\r\n  margin: 5px;\r\n}\r\nth {\r\n  padding: 5px;\r\n  color: white;\r\n  background: darkgray;\r\n}\r\ntd {\r\n  padding: 5px;\r\n  color: black;\r\n  background: #f0f0f0;\r\n}\r\n.err {\r\n  color: red;\r\n}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1&gt;Bookshelf&lt;\/h1&gt;\r\n&lt;p th:text=&quot;${msg}&quot;&gt;&lt;\/p&gt;\r\n&lt;form method=&quot;post&quot; action=&quot;\/bookshelf&quot; th:object=&quot;${formModel}&quot;&gt;\r\n  &lt;table&gt;\r\n    &lt;tr&gt;\r\n      &lt;td&gt;&lt;label for=&quot;name&quot;&gt;\u540d\u524d&lt;\/label&gt;&lt;\/td&gt;\r\n      &lt;td&gt;\r\n        &lt;input type=&quot;text&quot; name=&quot;name&quot; th:value=&quot;*{name}&quot;\r\n      \t\t\tth:errorclass=&quot;err&quot; \/&gt;\r\n      \t&lt;div th:if=&quot;${#fields.hasErrors('name')}&quot; th:errors=&quot;*{name}&quot;\r\n      \t\tth:errorclass=&quot;err&quot;&gt;&lt;\/div&gt;\r\n      &lt;\/td&gt;\r\n    &lt;\/tr&gt;\r\n    &lt;tr&gt;\r\n      &lt;td&gt;&lt;\/td&gt;\r\n      &lt;td&gt;&lt;input type=&quot;submit&quot; \/&gt;&lt;\/td&gt;\r\n    &lt;\/tr&gt;\r\n  &lt;\/table&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;hr \/&gt;\r\n&lt;table&gt;\r\n  &lt;tr&gt;\r\n    &lt;th&gt;ID&lt;\/th&gt;&lt;th&gt;\u540d\u524d&lt;\/th&gt;\r\n  &lt;\/tr&gt;\r\n  &lt;tr th:each=&quot;obj : ${datalist}&quot;&gt;\r\n    &lt;td th:text=&quot;${obj.id}&quot;&gt;&lt;\/td&gt;\r\n    &lt;td th:text=&quot;${obj.name}&quot;&gt;&lt;\/td&gt;\r\n  &lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p><strong>Bookshelf\u30a8\u30f3\u30c6\u30a3\u30c6\u30a3\u3092\u4f5c\u6210\u3059\u308b<\/strong><\/p>\n<p>src\/main\/java\/<br \/>\n\u2514jp.abc<br \/>\n\u3000\u2514Bookshelf.java<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.abc;\r\n\r\nimport javax.persistence.Column;\r\nimport javax.persistence.Entity;\r\nimport javax.persistence.GeneratedValue;\r\nimport javax.persistence.GenerationType;\r\nimport javax.persistence.Id;\r\nimport javax.validation.constraints.NotEmpty;\r\nimport javax.validation.constraints.NotNull;\r\n\r\n@Entity\r\npublic class Bookshelf {\r\n\t@Id\r\n\t@GeneratedValue(strategy = GenerationType.AUTO)\r\n\t@Column\r\n\t@NotNull\r\n\tprivate long id;\r\n\r\n\t@Column(length = 200, nullable = false)\r\n\t@NotEmpty\r\n\tprivate String name;\r\n\r\n\tpublic long getId() {\r\n\t\treturn id;\r\n\t}\r\n\r\n\tpublic void setId(long id) {\r\n\t\tthis.id = id;\r\n\t}\r\n\r\n\tpublic String getName() {\r\n\t\treturn name;\r\n\t}\r\n\r\n\tpublic void setName(String name) {\r\n\t\tthis.name = name;\r\n\t}\r\n}\r\n<\/pre>\n<p><strong>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3092\u4f5c\u6210\u3059\u308b<\/strong><\/p>\n<p>src\/main\/java\/<br \/>\n\u2514jp.abc<br \/>\n\u3000\u2514BookshelfController.java<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.abc;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\nimport org.springframework.web.bind.annotation.RequestMethod;\r\nimport org.springframework.web.servlet.ModelAndView;\r\n\r\n@Controller\r\npublic class BookshelfController {\r\n\t@RequestMapping(value = &quot;\/bookshelf&quot;, method = RequestMethod.GET)\r\n\tpublic ModelAndView index(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;bookshelf&quot;);\r\n\t\tmav.addObject(&quot;formModel&quot;, new Bookshelf());\r\n\t\tmav.addObject(&quot;datalist&quot;, null);\r\n\t\treturn mav;\r\n\t}\r\n\r\n}\r\n<\/pre>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Spring Boot\u306e\u5fa9\u7fd2 \u7c21\u5358\u306aWeb\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b\u3002 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d: bookshelf \u30d1\u30c3\u30b1\u30fc\u30b8\u540d: jp.abc \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3068\u3001pom.xml\u5185\u3067\u306eSpringBoot\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u304c2.1 &hellip; <a href=\"https:\/\/2019se3.satoshis.jp\/?p=254\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;8\u670819\u65e5&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,3],"tags":[],"_links":{"self":[{"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/254"}],"collection":[{"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=254"}],"version-history":[{"count":11,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/254\/revisions"}],"predecessor-version":[{"id":265,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/254\/revisions\/265"}],"wp:attachment":[{"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}