Spring boot 使用webpack devserver时访问Thymeleaf Spring Boot application.properties

Spring boot 使用webpack devserver时访问Thymeleaf Spring Boot application.properties,spring-boot,thymeleaf,webpack-dev-server,Spring Boot,Thymeleaf,Webpack Dev Server,在上浏览应用程序时,我可以从application.properties访问相关属性值http://localhost:8081,但不通过使用webpack devserverhttp://localhost:9090. webpack.dev.js(devserver) index.html <html> <head> . . <script th:inline="javascript">

在上浏览应用程序时,我可以从application.properties访问相关属性值http://localhost:8081,但不通过使用webpack devserverhttp://localhost:9090.

webpack.dev.js(devserver)

index.html

 <html>
    <head>
       .
       .
      <script th:inline="javascript">
        var SERVICES_URL = [[${servicesUrl}]];
        var MAPS_URL = [[${mapsUrl}]];
      </script>     
   </head>
   <body>
      <div id="react"></div>
      <script src="/bundle.js"></script> 
   </body>
</html>
在使用webpack devserver访问任何javascript文件中的变量SERVICES_URL时,我会得到以下错误,因为变量没有被Thymeleaf赋值

SyntaxError: missing ] after element list

我假设它在webpack devserver上不起作用,因为它只提供前端代码而不是嵌入式tomcat服务器,它还提供服务器端代码。

此问题的解决方案是从网页包配置文件中删除HtmlWebpackPlugin,以便索引不会从资源文件中加载,而是在Thymeleaf完成任务后从响应中加载

   plugins: [
      new CleanWebpackPlugin(),
//    new HtmlWebpackPlugin({
//       template: 'src/main/resources/templates/index.html',
//       title: 'Example Application'
//    }),
      new webpack.HotModuleReplacementPlugin(),
      new webpack.ProvidePlugin({
         $: 'jquery',
         jQuery: 'jquery',
         'window.jQuery': 'jquery',
         Popper: ['popper.js', 'default']
      })
  ],
SyntaxError: missing ] after element list
   plugins: [
      new CleanWebpackPlugin(),
//    new HtmlWebpackPlugin({
//       template: 'src/main/resources/templates/index.html',
//       title: 'Example Application'
//    }),
      new webpack.HotModuleReplacementPlugin(),
      new webpack.ProvidePlugin({
         $: 'jquery',
         jQuery: 'jquery',
         'window.jQuery': 'jquery',
         Popper: ['popper.js', 'default']
      })
  ],