<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Haikal Saadh</title>
    <description>The latest articles on DEV Community by Haikal Saadh (@tunaranch).</description>
    <link>https://dev.to/tunaranch</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F69275%2Fdb500e12-f3fa-4805-b94c-d24a041141fb.png</url>
      <title>DEV Community: Haikal Saadh</title>
      <link>https://dev.to/tunaranch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tunaranch"/>
    <language>en</language>
    <item>
      <title>Create a single page app with Spring Boot and Vue.js</title>
      <dc:creator>Haikal Saadh</dc:creator>
      <pubDate>Sun, 31 Mar 2019 07:39:49 +0000</pubDate>
      <link>https://dev.to/tunaranch/create-a-single-page-app-with-spring-boot-and-vue-js-2on</link>
      <guid>https://dev.to/tunaranch/create-a-single-page-app-with-spring-boot-and-vue-js-2on</guid>
      <description>

&lt;h1&gt;
  
  
  Objectives
&lt;/h1&gt;

&lt;p&gt;Create a single page app with &lt;a href="https://spring.io/projects/spring-boot"&gt;Spring Boot&lt;/a&gt; and &lt;a href="https://vuejs.org/v2/guide/"&gt;Vue.js&lt;/a&gt; with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One maven build for both frontend and backend.&lt;/li&gt;
&lt;li&gt;Frontend bundled into the Boot app.&lt;/li&gt;
&lt;li&gt;Use Vue router in router history mode, so that we don't have the &lt;code&gt;#&lt;/code&gt; in the url bar.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Prerequisites
&lt;/h1&gt;

&lt;p&gt;You'll need to install:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;npm (on macOS, you can simply &lt;code&gt;brew install npm&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cli.vuejs.org/guide/#components-of-the-system"&gt;vue-cli&lt;/a&gt; (&lt;code&gt;npm install -g @vue/cli&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://jdk.java.net/11/"&gt;JDK&lt;/a&gt; (This example uses java 11, but any will do, just change the java version when creating the spring project)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://httpie.org"&gt;httpie&lt;/a&gt; (optional. You can use &lt;a href="https://start.spring.io"&gt;https://start.spring.io&lt;/a&gt; to bootstrap your Spring project).&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Step by step
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Create a Spring Boot Project
&lt;/h2&gt;

&lt;p&gt;From a terminal&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;http https://start.spring.io/starter.tgz &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nv"&gt;artifactId&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;cafe &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nv"&gt;javaVersion&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;11 &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nv"&gt;language&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;kotlin &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;Cafe &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nv"&gt;dependencies&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;webflux,devtools,actuator &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nv"&gt;baseDir&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;cafe | &lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-xzvf&lt;/span&gt; -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will give you a basic spring boot project under &lt;code&gt;cafe/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Test the build to make sure it works:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./mvnw &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;INFO] Scanning &lt;span class="k"&gt;for &lt;/span&gt;projects...
&lt;span class="o"&gt;[&lt;/span&gt;INFO] 
&lt;span class="o"&gt;[&lt;/span&gt;INFO] &lt;span class="nt"&gt;--------------------------&lt;/span&gt;&amp;lt; com.example:cafe &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;--------------------------&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;INFO] Building Cafe 0.0.1-SNAPSHOT
&lt;span class="o"&gt;[&lt;/span&gt;INFO] &lt;span class="nt"&gt;--------------------------------&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt; jar &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nt"&gt;---------------------------------&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;INFO] 
...
&lt;span class="o"&gt;[&lt;/span&gt;INFO] 
&lt;span class="o"&gt;[&lt;/span&gt;INFO] Results:
&lt;span class="o"&gt;[&lt;/span&gt;INFO] 
&lt;span class="o"&gt;[&lt;/span&gt;INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
&lt;span class="o"&gt;[&lt;/span&gt;INFO] 
&lt;span class="o"&gt;[&lt;/span&gt;INFO] &lt;span class="nt"&gt;------------------------------------------------------------------------&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;INFO] BUILD SUCCESS
&lt;span class="o"&gt;[&lt;/span&gt;INFO] &lt;span class="nt"&gt;------------------------------------------------------------------------&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;INFO] Total &lt;span class="nb"&gt;time&lt;/span&gt;:  13.718 s
&lt;span class="o"&gt;[&lt;/span&gt;INFO] Finished at: 2019-03-30T12:19:24+10:00
&lt;span class="o"&gt;[&lt;/span&gt;INFO] &lt;span class="nt"&gt;------------------------------------------------------------------------&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Create a Vue project
&lt;/h2&gt;

&lt;p&gt;Use vue-cli to generate a Hello World Vue CLI project. &lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;src/main
&lt;span class="nv"&gt;$ &lt;/span&gt;vue create frontend &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--no-git&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s1"&gt;'{
  "useConfigFiles": false,
  "plugins": {
    "@vue/cli-plugin-babel": {},
    "@vue/cli-plugin-typescript": {
      "classComponent": true,
      "useTsWithBabel": true
    },
    "@vue/cli-plugin-eslint": {
      "config": "standard",
      "lintOn": [
        "save"
      ]
    }
  },
  "router": true,
  "routerHistoryMode": true,
  "cssPreprocessor": "node-sass"
}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Configure javascript build output directory
&lt;/h2&gt;

&lt;p&gt;Configure webpack so that compiled static content is under &lt;code&gt;target&lt;/code&gt;, in keeping with maven conventions. Spring Boot serves static resources from &lt;code&gt;public&lt;/code&gt; at the classpath root, so we'll take that into consideration as well.    &lt;/p&gt;

&lt;p&gt;Edit &lt;code&gt;src/main/frontend/vue.config.js&lt;/code&gt;:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;module.exports&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;outputDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;'../../../target/frontend/public'&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Configure the maven build to compile the Vue project
&lt;/h2&gt;

&lt;p&gt;We need to make sure the built static resources end up in the correct place so the maven build and spring know about it&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure the npm build
&lt;/h3&gt;

&lt;p&gt;Add this plugin to your &lt;code&gt;pom.xml&lt;/code&gt;'s &lt;code&gt;plugins&lt;/code&gt; section:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;project&amp;gt;&lt;/span&gt;
  ...
  &lt;span class="nt"&gt;&amp;lt;build&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;
      ...
      &lt;span class="nt"&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;com.github.eirslett&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;frontend-maven-plugin&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.7.5&lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;executions&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;execution&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;id&amp;gt;&lt;/span&gt;install node and npm&lt;span class="nt"&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;goals&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;install-node-and-npm&lt;span class="nt"&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/goals&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;nodeVersion&amp;gt;&lt;/span&gt;v11.12.0&lt;span class="nt"&gt;&amp;lt;/nodeVersion&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/execution&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;execution&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;id&amp;gt;&lt;/span&gt;npm install&lt;span class="nt"&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;goals&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;npm&lt;span class="nt"&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/goals&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;arguments&amp;gt;&lt;/span&gt;install&lt;span class="nt"&gt;&amp;lt;/arguments&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/execution&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;execution&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;id&amp;gt;&lt;/span&gt;npm build&lt;span class="nt"&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;goals&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;npm&lt;span class="nt"&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/goals&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;phase&amp;gt;&lt;/span&gt;generate-resources&lt;span class="nt"&gt;&amp;lt;/phase&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;arguments&amp;gt;&lt;/span&gt;run build&lt;span class="nt"&gt;&amp;lt;/arguments&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/execution&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/executions&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;workingDirectory&amp;gt;&lt;/span&gt;${project.basedir}/src/main/frontend&lt;span class="nt"&gt;&amp;lt;/workingDirectory&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;installDirectory&amp;gt;&lt;/span&gt;${project.build.directory}/node&lt;span class="nt"&gt;&amp;lt;/installDirectory&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
      ...
    &lt;span class="nt"&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/build&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Test it out by running &lt;code&gt;./mvnw process-resources&lt;/code&gt;. You should see the output of the npm build in &lt;code&gt;target/frontend/&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add compiled static resources to the maven build
&lt;/h3&gt;

&lt;p&gt;Add the generated static component as resource to your build, by adding a &lt;code&gt;resources&lt;/code&gt; section to your &lt;code&gt;pom.xml&lt;/code&gt;.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight xml"&gt;&lt;code&gt;
&lt;span class="nt"&gt;&amp;lt;project&amp;gt;&lt;/span&gt;
  ...
  &lt;span class="nt"&gt;&amp;lt;build&amp;gt;&lt;/span&gt;
    ...
    &lt;span class="nt"&gt;&amp;lt;resources&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;resource&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;directory&amp;gt;&lt;/span&gt;${project.build.directory}/frontend&lt;span class="nt"&gt;&amp;lt;/directory&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/resource&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/resources&amp;gt;&lt;/span&gt;
    ...
  &lt;span class="nt"&gt;&amp;lt;/build&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Configure spring boot plugin to include static resources
&lt;/h3&gt;

&lt;p&gt;Add this extra &lt;code&gt;configuration&lt;/code&gt; element to the &lt;code&gt;spring-boot-maven-plugin&lt;/code&gt;'s config so it will be treated as part of the Spring Boot app.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;project&amp;gt;&lt;/span&gt;
  ...
  &lt;span class="nt"&gt;&amp;lt;build&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;
      ...
      &lt;span class="nt"&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework.boot&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-boot-maven-plugin&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;folders&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;folder&amp;gt;&lt;/span&gt;${project.build.directory}/frontend&lt;span class="nt"&gt;&amp;lt;/folder&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/folders&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
      ...
    &lt;span class="nt"&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/build&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Almost there! If you run &lt;code&gt;./mvnw spring-boot:run&lt;/code&gt; and point your browser to &lt;a href="http://localhost:8080/index.html"&gt;http://localhost:8080/index.html&lt;/a&gt;, you should see half of the vue hello world page. We need to do some more work on the backend to things lined up properly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rewrite URLs to make router history mode work
&lt;/h2&gt;

&lt;p&gt;Create a filter that routes everything that's not a bunch of pre-set paths to the static index page.&lt;/p&gt;

&lt;p&gt;We will let boot handle the following paths:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/actuator&lt;/code&gt;: Spring Boot's actuator has endpoints for health checks, metrics etc&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/api&lt;/code&gt;: this app's backend API can go under this path&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/js&lt;/code&gt;, &lt;code&gt;/css&lt;/code&gt;, &lt;code&gt;/img&lt;/code&gt;: static resources&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.cafe.web&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.stereotype.Component&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.server.ServerWebExchange&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.server.WebFilter&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.server.WebFilterChain&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;reactor.core.publisher.Mono&lt;/span&gt;

&lt;span class="nd"&gt;@Component&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VueRoutePathFilter&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;WebFilter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;companion&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;BOOT_PATHS&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;listOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="s"&gt;"/actuator/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s"&gt;"/api/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s"&gt;"/js/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s"&gt;"/css/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s"&gt;"/img/"&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;SPA_PATH&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"/index.html"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;exchange&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ServerWebExchange&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="nv"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;WebFilterChain&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;Mono&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Void&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isApiPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exchange&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exchange&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;chain&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exchange&lt;/span&gt;
                &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mutate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exchange&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mutate&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SPA_PATH&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
                &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;isApiPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;BOOT_PATHS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;any&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should now be able to hit &lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt; to get the vue Hello World page.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/tunaranch/spring-boot-vue-spa/tree/create-hello-world-spa"&gt;sample code&lt;/a&gt; for this project is on GitHub. Enjoy!&lt;/p&gt;


</description>
      <category>springboot</category>
      <category>vue</category>
      <category>maven</category>
    </item>
  </channel>
</rss>
