title: OpenUI5 with Spring Boot Web - can these work together?
body: <p>I'm trying to create a very simple Spring Boot 1.3.3 Web application with Thymeleaf and embedded Tomcat using OpenUI5 as the client-side javascript UI library... <strong>but I can't seem to get OpenUI5 to load the data-sap-ui-resourceroots. Is this supposed to be possible?</strong></p>
  
  <p>I started by going to <a href="https://start.spring.io/" rel="nofollow">start.spring.io</a> and generating a maven project with Web and Thymeleaf dependencies and then added in a basic OpenUI5 structure with an XML view. I followed the following tutorials:</p>
  
  <ol>
  <li><a href="https://spring.io/guides/gs/serving-web-content/" rel="nofollow">Serving Web Content with Spring MVC</a></li>
  <li><a href="https://openui5.hana.ondemand.com/#docs/guide/1409791afe4747319a3b23a1e2fc7064.html" rel="nofollow">OpenUI5 Walkthrough - Step 4: XML Views</a></li>
  </ol>
  
  <p>I ended up with the following project structure:</p>
  
  <pre><code>root
  ├── src
  │    ├── main
  │    │    ├── java
  │    │    │   └── myPackage
  │    │    │       ├── controllers
  │    │    │       │   └── LandingPageController.java
  │    │    │       └── Application.java
  │    │    └── resources
  │    │        ├── application.properties
  │    │        ├── static
  │    │        │   └── webapp
  │    │        │       └── view
  │    │        │           └── App.view.xml
  │    │        └── templates
  │    │            └── landingPage.html
  │    └── test
  │        └── java
  │            └── myPackage
  │                └── ApplicationTests.java
  │
  └── pom.xml
  </code></pre>
  
  <p>Even though it's all basically standard from those tutorials, for completeness, I'll include my source code:</p>
  
  <p>Application.java:</p>
  
  <pre><code>package myPackage;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class Application {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>LandingPageController.java:</p>
  
  <pre><code>package myPackage.controllers;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  @Controller
  @RequestMapping("/")
  public class LandingPageController {
  
      @RequestMapping(method=RequestMethod.GET)
      public String redirect() {
          return "landingPage";
      }
  }
  </code></pre>
  
  <p>landingPage.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;SAPUI5 Walkthrough&lt;/title&gt;
      &lt;script
       id="sap-ui-bootstrap"
       src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" 
       data-sap-ui-theme="sap_bluecrystal"
       data-sap-ui-libs="sap.m"
       data-sap-ui-compatVersion="edge"
       data-sap-ui-preload="async" 
       data-sap-ui-resourceroots='{
          "sap.ui.demo.wt": "./"
       }'&gt;
      &lt;/script&gt;
      &lt;script&gt;
       sap.ui.getCore().attachInit(function () {
           sap.ui.xmlview({
               viewName : "sap.ui.demo.wt.view.App"
            }).placeAt("content");
       });
      &lt;/script&gt;
    &lt;/head&gt;
    &lt;body class="sapUiBody" id="content"&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>App.view.xml:</p>
  
  <pre><code>&lt;mvc:View
     xmlns="sap.m"
     xmlns:mvc="sap.ui.core.mvc"&gt;
     &lt;Text text="Hello World"/&gt;
  &lt;/mvc:View&gt;
  </code></pre>
  
  <p>My application.properties file is empty and the pom.xml is exactly what was generated by the <a href="https://start.spring.io/" rel="nofollow">Spring Initializr</a>.</p>
  
  <p>I believe the issue is with this line in the landingPage.html, but I don't know what else to put other than "./":</p>
  
  <pre><code>data-sap-ui-resourceroots='{
          "sap.ui.demo.wt": "./"
       }
  </code></pre>
  
  <p>I was able to get this to work up to step 3 in the OpenUI5 tutorial; however, it seems that once I have to define the view in an XML file, the OpenUI5 library cannot locate it. I don't know where else to put the App.view.xml file, I would have thought that anywhere under the static folder would be fine...</p>
  
  <p>I'm not sure if this has to do with the fact that I'm using an embedded Tomcat, but I'd like this to work using embedded Tomcat.</p>
  
  <p>Any suggestions on how I can make this work?</p>