微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何配置React App在Spring Boot后端在localhost 8080中启动

如何解决如何配置React App在Spring Boot后端在localhost 8080中启动

这是我的package.json反应。

//*** prepare text for printing
 public Node getPrintableText(){

   Label text = new Label();

   StringBuilder stringBuilder = new StringBuilder();

   stringBuilder.append("*********************************************" + "\n");
   stringBuilder.append("             " + companyName + "            \n");
   stringBuilder.append("*********************************************" + "\n");

   stringBuilder.append("Location: " + companyLocation + "\n");
   stringBuilder.append("Contact Us: " + phoneNumber + "\n");
   stringBuilder.append("TIN: " + tinNumber + "\n");
   stringBuilder.append("Receipt No: " + transactionGeneratedId + "\n");
   stringBuilder.append("Date: " + getCurrentTimeStamp() + "\n");
   stringBuilder.append("---------------------------------------------" + "\n");

 // get each product and add to printing list
 for(Products product: productList){

    if(product.getProduct_name().length() > 10){
        // getting the first 11 characters of the product name
        String name = product.getProduct_name().substring(0,9)+ "...";
        stringBuilder.append(product.getQuantity_purchased() + " x " + name +  "          " + currencySymbol + product.getUnit_selling_price() + "\n");

    }else{
        stringBuilder.append(product.getQuantity_purchased() + " x " + product.getProduct_name()
                +  "            " + currencySymbol + product.getUnit_selling_price() + "\n");
    }

    stringBuilder.append("Subtotal                 "  + currencySymbol + (Double.parseDouble(product.getQuantity_purchased()) *
            Double.parseDouble(product.getUnit_selling_price())) + "\n");
    stringBuilder.append("---------------------------------------------" + "\n");

 }

   // get overall total
   stringBuilder.append("Overall Total             " + currencySymbol + totalPrice + "\n");

   String cashReceived = fieldCashReceived.getText().trim();

   // get total amount
   stringBuilder.append("Amount Paid               " + currencySymbol + cashReceived + "\n");

   double balance = totalPrice - Double.parseDouble(cashReceived);

   stringBuilder.append("_____________________________________________" + "\n");

   // get balance
   stringBuilder.append("Balance                   " + currencySymbol + balance + "\n");

   stringBuilder.append("*********************************************" + "\n");

   stringBuilder.append("Thank you so much!" + "\n");

   stringBuilder.append("*******************************************");

   text.setText(stringBuilder.toString());

   return text;
}

我在package.json文件中使用了代理,但是它对我不起作用。添加此代理后,它没有显示任何错误,但是也位于本地host3000中。

解决方法

React是常规的前端框架。这意味着最终,它将构建到一堆js文件中。因此react-scripts build。您应该将这些文件部署到可以提供静态文件的适当HTTP服务器。进行检查以使HTTP文件服务器脱离节点https://stackoverflow.com/a/16350826/3849555react-scripts start只是出于开发目的而启动Web服务器。请勿将其用作真实的Web服务器。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。