{"id":399,"date":"2017-12-25T01:36:42","date_gmt":"2017-12-25T01:36:42","guid":{"rendered":"http:\/\/emacslisp.com\/?p=399"},"modified":"2017-12-25T12:41:02","modified_gmt":"2017-12-25T12:41:02","slug":"spring-mvc-and-spring-boot-with-angular-js","status":"publish","type":"post","link":"http:\/\/emacslisp.com\/?p=399","title":{"rendered":"Spring MVC and Spring Boot with Angular.js"},"content":{"rendered":"<p>1. Download STS, there are two ways to use spring tools. First, eclipse with its plugins,<br \/>\ngo to eclipse marketing place. I didn&#8217;t recommend using raw eclipse with spring plugins,<br \/>\nbecause during I develop, I find eclipse with plugin may fail to work.sometime, it may reinstall every time when eclipse restart.<br \/>\n<strong>I highly recommend to download STS whole toolset form https:\/\/spring.io\/tools\/sts<\/strong>. Once it is downloaded and unpacked, it will be used as eclipse.<\/p>\n<p>2. Maven is mainly project management tools. Two important concept.<br \/>\n<strong>Parent POM and Child POM<\/strong>, in parent project, it has pom.xml which will contains child project pom.xml as module, while child project will also reference parent project in its POM.xml<\/p>\n<pre lang=\"xml\" line=\"1\" escaped=\"true\"> \r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project>\r\n...\r\n        <groupId>org.springframework.samples<\/groupId>\r\n\t<artifactId>spring-petclinic-angular1<\/artifactId>\r\n\t<version>2.0.0-M3<\/version>\r\n\t<name>Spring Petclinic :: Parent POM<\/name>\r\n\t<packaging>pom<\/packaging>\r\n\r\n\t<modules>\r\n\t\t<module>spring-petclinic-client<\/module>\r\n\t\t<module>spring-petclinic-server<\/module>\r\n\t<\/modules>\r\n...\r\n<\/project>\r\n<\/pre>\n<pre lang=\"xml\" line=\"1\" escaped=\"true\"> \r\n<project>\r\n...\r\n\t<parent>\r\n\t\t<groupId>org.springframework.samples<\/groupId>\r\n\t\t<artifactId>spring-petclinic-angular1<\/artifactId>\r\n\t\t<version>2.0.0-M3<\/version>\r\n\t<\/parent>\r\n...        \r\n<\/project>\r\n<\/pre>\n<p>3. Create parent project<br \/>\n<a href=\"http:\/\/emacslisp.com\/wp-content\/uploads\/2017\/12\/new_project.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-402\" src=\"http:\/\/emacslisp.com\/wp-content\/uploads\/2017\/12\/new_project.png\" alt=\"new_project\" width=\"1200\" height=\"1190\" \/><\/a><\/p>\n<p>    <1>.choose &#8216;Spring Start Project&#8217;, click &#8216;next&#8217; following by wizard filling with information.<br \/>\n    <2>.delete all folders, only keep two folders &#8216;spring-petclinic-client&#8217; and &#8216;spring-petclinic-server&#8217; for child projects<br \/>\n<a href=\"http:\/\/emacslisp.com\/wp-content\/uploads\/2017\/12\/Screen-Shot-2017-12-25-at-10.49.51-pm.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/emacslisp.com\/wp-content\/uploads\/2017\/12\/Screen-Shot-2017-12-25-at-10.49.51-pm.png\" alt=\"Screen Shot 2017-12-25 at 10.49.51 pm\" width=\"696\" height=\"208\" class=\"alignnone size-full wp-image-403\" \/><\/a><\/p>\n<p>4. Create child frontend project<br \/>\n   <1> choose &#8216;Spring Start Project&#8217;, click &#8216;next&#8217; following by wizard filling with information.<br \/>\n   <2> delete &#8216;src\/main\/java&#8217;, &#8216;src\/main\/resources&#8217;, &#8216;src\/test\/java&#8217;<br \/>\n   <3> add bower.json, glupfile.js, package.json and keep src as resource.<br \/>\n   <a href=\"http:\/\/emacslisp.com\/wp-content\/uploads\/2017\/12\/Screen-Shot-2017-12-25-at-11.20.10-pm.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/emacslisp.com\/wp-content\/uploads\/2017\/12\/Screen-Shot-2017-12-25-at-11.20.10-pm.png\" alt=\"Screen Shot 2017-12-25 at 11.20.10 pm\" width=\"682\" height=\"854\" class=\"alignnone size-full wp-image-405\" \/><\/a><\/p>\n<p>5. create child backend project<br \/>\n   <1> choose &#8216;Spring Start Project&#8217;, click &#8216;next&#8217; following by wizard filling with information.<br \/>\nfor backend, project is OK to keep original structure.<br \/>\n restful controller will map url to method.<br \/>\n @PostMapping(&#8220;\/owners\/{ownerId}\/pets\/{petId}\/visits&#8221;)<br \/>\n @ResponseStatus(HttpStatus.NO_CONTENT)<br \/>\n<a href=\"http:\/\/emacslisp.com\/wp-content\/uploads\/2017\/12\/Screen-Shot-2017-12-25-at-11.24.24-pm.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/emacslisp.com\/wp-content\/uploads\/2017\/12\/Screen-Shot-2017-12-25-at-11.24.24-pm.png\" alt=\"Screen Shot 2017-12-25 at 11.24.24 pm\" width=\"2254\" height=\"876\" class=\"alignnone size-full wp-image-406\" \/><\/a><\/p>\n<p>6. run &#8216;mvn package -DskipTest&#8217; on parent project folder to build all project.<br \/>\nNow we finish all project structure creating process.<br \/>\nfor more code, https:\/\/github.com\/emacslisp\/spring-project\/tree\/master\/spring-petclinic-angular1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Download STS, there are two ways to use spring tools. First, eclipse with its plugins, go to eclipse marketing place. I didn&#8217;t recommend using raw eclipse with spring plugins, because during I develop, I find eclipse with plugin may fail to work.sometime, it may reinstall every time when eclipse restart. I highly recommend to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-399","post","type-post","status-publish","format-standard","hentry","category-spring"],"_links":{"self":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=399"}],"version-history":[{"count":11,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/399\/revisions"}],"predecessor-version":[{"id":415,"href":"http:\/\/emacslisp.com\/index.php?rest_route=\/wp\/v2\/posts\/399\/revisions\/415"}],"wp:attachment":[{"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=399"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/emacslisp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}