index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>Springboot react webpack - Febbweiss</title>
  9. <link rel="shortcut icon" href="../../img/favicon.ico">
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
  11. <link rel="stylesheet" href="../../css/theme.css" type="text/css" />
  12. <link rel="stylesheet" href="../../css/theme_extra.css" type="text/css" />
  13. <link rel="stylesheet" href="../../css/highlight.css">
  14. <link href="../../extra/css/extra.css" rel="stylesheet">
  15. <link href="../../extra/css/sis.css" rel="stylesheet">
  16. <script>
  17. // Current page data
  18. var mkdocs_page_name = "Springboot react webpack";
  19. var mkdocs_page_input_path = "development/springboot_react_webpack.md";
  20. var mkdocs_page_url = "/development/springboot_react_webpack/";
  21. </script>
  22. <script src="../../js/jquery-2.1.1.min.js"></script>
  23. <script src="../../js/modernizr-2.8.3.min.js"></script>
  24. <script type="text/javascript" src="../../js/highlight.pack.js"></script>
  25. <script src="../../js/theme.js"></script>
  26. <script src="../../extra/js/pacman.js"></script>
  27. <script src="../../extra/js/pyramid.js"></script>
  28. <script src="../../extra/js/sis.js"></script>
  29. <script src="../../extra/js/yahtzee.js"></script>
  30. </head>
  31. <body class="wy-body-for-nav" role="document">
  32. <div class="wy-grid-for-nav">
  33. <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
  34. <div class="wy-side-nav-search">
  35. <a href="../.." class="icon icon-home"> Febbweiss</a>
  36. <div role="search">
  37. <form id ="rtd-search-form" class="wy-form" action="../../search.html" method="get">
  38. <input type="text" name="q" placeholder="Search docs" />
  39. </form>
  40. </div>
  41. </div>
  42. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  43. <ul class="current">
  44. <li>
  45. <li class="toctree-l1 ">
  46. <a class="" href="../..">Home</a>
  47. </li>
  48. <li>
  49. <li>
  50. <ul class="subnav">
  51. <li><span>Development</span></li>
  52. <li class="toctree-l1 ">
  53. <a class="" href="../cloudbudget/">Cloudbudget</a>
  54. </li>
  55. <li class="toctree-l1 ">
  56. <a class="" href="../cloudbudget_angularjs/">Cloudbudget angularjs</a>
  57. </li>
  58. <li class="toctree-l1 ">
  59. <a class="" href="../filebrowser_durandal_widget/">Filebrowser durandal widget</a>
  60. </li>
  61. <li class="toctree-l1 ">
  62. <a class="" href="../java_small_projects/">Java small projects</a>
  63. </li>
  64. <li class="toctree-l1 ">
  65. <a class="" href="../library_reader/">Library reader</a>
  66. </li>
  67. <li class="toctree-l1 ">
  68. <a class="" href="../project_deployer/">Project deployer</a>
  69. </li>
  70. <li class="toctree-l1 ">
  71. <a class="" href="../scrabble_resolver/">Scrabble resolver</a>
  72. </li>
  73. <li class="toctree-l1 current">
  74. <a class="current" href="./">Springboot react webpack</a>
  75. <ul>
  76. <li class="toctree-l3"><a href="#springboot-react-webpack">springboot-react-webpack</a></li>
  77. <li><a class="toctree-l4" href="#profile">Profile</a></li>
  78. <li><a class="toctree-l4" href="#launching">Launching</a></li>
  79. <li><a class="toctree-l4" href="#configuration">Configuration</a></li>
  80. <li><a class="toctree-l4" href="#spring-boot">Spring Boot</a></li>
  81. <li><a class="toctree-l4" href="#react">React</a></li>
  82. <li><a class="toctree-l4" href="#webpack">Webpack</a></li>
  83. <li><a class="toctree-l4" href="#plugin-release">Plugin release</a></li>
  84. <li><a class="toctree-l4" href="#plugin-cloudfoundry">Plugin CloudFoundry</a></li>
  85. <li><a class="toctree-l4" href="#plugin-docker">Plugin Docker</a></li>
  86. </ul>
  87. </li>
  88. </ul>
  89. <li>
  90. <li>
  91. <ul class="subnav">
  92. <li><span>Docker</span></li>
  93. <li class="toctree-l1 ">
  94. <a class="" href="../../docker/docker_apache_log_generator/">Docker apache log generator</a>
  95. </li>
  96. <li class="toctree-l1 ">
  97. <a class="" href="../../docker/docker_gocd/">Docker gocd</a>
  98. </li>
  99. <li class="toctree-l1 ">
  100. <a class="" href="../../docker/docker_java_log_generator/">Docker java log generator</a>
  101. </li>
  102. <li class="toctree-l1 ">
  103. <a class="" href="../../docker/docker_log_centralizer/">Docker log centralizer</a>
  104. </li>
  105. </ul>
  106. <li>
  107. <li>
  108. <ul class="subnav">
  109. <li><span>Games</span></li>
  110. <li class="toctree-l1 ">
  111. <a class="" href="../../games/Space_invaders_stories/">Space invaders stories</a>
  112. </li>
  113. <li class="toctree-l1 ">
  114. <a class="" href="../../games/pacman/">Pacman</a>
  115. </li>
  116. <li class="toctree-l1 ">
  117. <a class="" href="../../games/pyramid/">Pyramid</a>
  118. </li>
  119. <li class="toctree-l1 ">
  120. <a class="" href="../../games/wordfighters/">Wordfighters</a>
  121. </li>
  122. <li class="toctree-l1 ">
  123. <a class="" href="../../games/yahtzee/">Yahtzee</a>
  124. </li>
  125. </ul>
  126. <li>
  127. </ul>
  128. </div>
  129. &nbsp;
  130. </nav>
  131. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  132. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  133. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  134. <a href="../..">Febbweiss</a>
  135. </nav>
  136. <div class="wy-nav-content">
  137. <div class="rst-content">
  138. <div role="navigation" aria-label="breadcrumbs navigation">
  139. <ul class="wy-breadcrumbs">
  140. <li><a href="../..">Docs</a> &raquo;</li>
  141. <li>Development &raquo;</li>
  142. <li>Springboot react webpack</li>
  143. <li class="wy-breadcrumbs-aside">
  144. <a href="https://github.com/febbweiss/" class="icon icon-github"> Edit on GitHub</a>
  145. </li>
  146. </ul>
  147. <hr/>
  148. </div>
  149. <div role="main">
  150. <div class="section">
  151. <h1 id="springboot-react-webpack">springboot-react-webpack</h1>
  152. <p>A demo project with Spring Boot, React and Webpack</p>
  153. <p>This project includes :</p>
  154. <ul>
  155. <li>Spring Boot as backend resource</li>
  156. <li>React as client JS framework</li>
  157. <li>webpack to translate JSX to JS and manage client resources link</li>
  158. <li>maven-release-plugin</li>
  159. <li>cf-maven-plugin</li>
  160. <li>docker-maven-plugin (from Spotify)</li>
  161. </ul>
  162. <h2 id="profile">Profile</h2>
  163. <p>There are 3 profiles :</p>
  164. <ul>
  165. <li>the default one (without specification) is for development mode.</li>
  166. <li><em>production</em> used to generate the production ready client resources</li>
  167. <li><em>docker</em> to access to the Docker plugin and generate an image</li>
  168. </ul>
  169. <h2 id="launching">Launching</h2>
  170. <p>To launch this project, just use the following command line :</p>
  171. <p>In development mode :</p>
  172. <pre><code>mvn clean spring-boot:run
  173. npm run watch
  174. </code></pre>
  175. <p>In production mode :</p>
  176. <pre><code>mvn clean spring-boot:run -P production
  177. </code></pre>
  178. <p>Without a profile, you have to run the webpack watcher to deliver client resources. With the <em>production</em> profile, no needs to launch the wepback watcher.</p>
  179. <h2 id="configuration">Configuration</h2>
  180. <p>To use the CloudFoundry and Release plugins, the <em>settings.xml</em> must contains the following lines :</p>
  181. <pre><code class="xml"> &lt;servers&gt;
  182. &lt;server&gt;
  183. &lt;id&gt;cloudfoundry&lt;/id&gt;
  184. &lt;username&gt;username&lt;/username&gt;
  185. &lt;password&gt;password&lt;/password&gt;
  186. &lt;/server&gt;
  187. &lt;server&gt;
  188. &lt;id&gt;github&lt;/id&gt;
  189. &lt;username&gt;username&lt;/username&gt;
  190. &lt;password&gt;password&lt;/password&gt;
  191. &lt;/server&gt;
  192. &lt;/servers&gt;
  193. </code></pre>
  194. <h2 id="spring-boot">Spring Boot</h2>
  195. <p>Spring Boot is used as the backend server. It provides the HTML pages and the REST endpoints.
  196. React is server side compiled at runtime using nashorn.</p>
  197. <h2 id="react">React</h2>
  198. <p>React is the client side library. It's possible to write JSX which will be translate by webpack.</p>
  199. <h2 id="webpack">Webpack</h2>
  200. <h3 id="configuration_1">Configuration</h3>
  201. <p>Webpack configuration is done by the <em>webpack.config.js</em> file at the project's root.</p>
  202. <h3 id="usage">Usage</h3>
  203. <p>Webpack is launched at the <em>generate-resources</em> maven phase.
  204. In this configuration, webpack provides resources (JS and CSS) for commons librairies and custom JS scripts. It takes in account LESS. The HTML final resource is generated from a template adding the needed resources.
  205. Using the default profile and the watcher, the HotModuleReplacement module is activated, so no need to refresh the page when updating a JS or a CSS, webpack does it.</p>
  206. <h2 id="plugin-release">Plugin release</h2>
  207. <h3 id="configuration_2">Configuration</h3>
  208. <p>To manage the release process with Git, you have to replace the link in the <em>developerConnection</em> tag with the Git project URL.</p>
  209. <h3 id="usage_1">Usage</h3>
  210. <p>The <em>maven-release-plugin</em> allows to release an app tagging the repository. A release is :
  211. <em> changing from SNAPSHOT to stable
  212. </em> creating a tag (locally and remotely)
  213. * increasing the SNAPSHOT version</p>
  214. <p>Two steps :</p>
  215. <pre><code>mvn release:prepare
  216. mvn release:perform
  217. </code></pre>
  218. <p>To rollback a <em>prepare</em> :</p>
  219. <pre><code>mvn release:rollback
  220. </code></pre>
  221. <p>To test the release :</p>
  222. <pre><code>mvn -DdryRun=true release:prepare
  223. mvn release:clean (test cleaning)
  224. </code></pre>
  225. <h3 id="documentation">Documentation</h3>
  226. <p><a href="https://maven.apache.org/maven-release/maven-release-plugin/index.html">https://maven.apache.org/maven-release/maven-release-plugin/index.html</a></p>
  227. <h2 id="plugin-cloudfoundry">Plugin CloudFoundry</h2>
  228. <h3 id="configuration_3">Configuration</h3>
  229. <p>Change the <em>TOFILL</em> strings in the comment plugin's section.</p>
  230. <h3 id="usage_2">Usage</h3>
  231. <p>The <em>cf-maven-plugin</em> plugin allows to manage the application in a CloudFoundry platform and specifically to push it :</p>
  232. <pre><code>mvn cf:push
  233. </code></pre>
  234. <h3 id="documentation_1">Documentation</h3>
  235. <p><a href="http://docs.cloudfoundry.org/buildpacks/java/build-tool-int.html">http://docs.cloudfoundry.org/buildpacks/java/build-tool-int.html</a></p>
  236. <h2 id="plugin-docker">Plugin Docker</h2>
  237. <h3 id="configuration_4">Configuration</h3>
  238. <p>The <em>docker-maven-plugin</em> (from Spotify) plugin has no configuration.</p>
  239. <h3 id="usage_3">Usage</h3>
  240. <p>The default project packaging (for CloudFoundry) is a WAR. In the Docker image, we use a JAR. To use this plugin (and the correct packaging), use the <em>docker</em> profile :</p>
  241. <pre><code>mvn package -P docker
  242. </code></pre>
  243. <p>This command generates a local Docker image. To manage it, use the <em>docker</em> profile to access the <em>docker-maven-plugin</em> (such as push it).</p>
  244. <h3 id="documentation_2">Documentation</h3>
  245. <p><a href="https://github.com/spotify/docker-maven-plugin">https://github.com/spotify/docker-maven-plugin</a></p>
  246. <p><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.min.css" />
  247. <!--[if lt IE 9]>
  248. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.0/gh-fork-ribbon.ie.min.css" />
  249. <![endif]-->
  250. <a class="github-fork-ribbon" href="https://github.com/Febbweiss/springboot-react-webpack" target="_blank" title="Fork me on GitHub">Fork me on GitHub</a></p>
  251. </div>
  252. </div>
  253. <footer>
  254. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  255. <a href="../../docker/docker_apache_log_generator/" class="btn btn-neutral float-right" title="Docker apache log generator">Next <span class="icon icon-circle-arrow-right"></span></a>
  256. <a href="../scrabble_resolver/" class="btn btn-neutral" title="Scrabble resolver"><span class="icon icon-circle-arrow-left"></span> Previous</a>
  257. </div>
  258. <hr/>
  259. <div role="contentinfo">
  260. <!-- Copyright etc -->
  261. </div>
  262. Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  263. </footer>
  264. </div>
  265. </div>
  266. </section>
  267. </div>
  268. <div class="rst-versions" role="note" style="cursor: pointer">
  269. <span class="rst-current-version" data-toggle="rst-current-version">
  270. <a href="https://github.com/febbweiss/" class="icon icon-github" style="float: left; color: #fcfcfc"> GitHub</a>
  271. <span><a href="../scrabble_resolver/" style="color: #fcfcfc;">&laquo; Previous</a></span>
  272. <span style="margin-left: 15px"><a href="../../docker/docker_apache_log_generator/" style="color: #fcfcfc">Next &raquo;</a></span>
  273. </span>
  274. </div>
  275. </body>
  276. </html>