部署后,Angular代码未在服务器上运行

时间:2019-10-23 11:15:53

标签: angular tomcat

我正在使用角度8

当我使用“ ng build”或“ ng build --prod true”在本地构建项目时,它的工作正常。

   local URL is http://localhost:4200/apw/

但是当我在服务器上部署我的代码时(服务器正在使用maven angular插件来构建和部署代码),它无法正常工作(例如当我使用tomcat服务器运行构建时) 并在https://ciigate.apexxfintech.com/apw/

上运行代码

它在控制台中显示错误,无法找到主要文件,如main.js,pollyfills.ts,runtime.js等。 所以在https://ciigate.apexxfintech.com/apw/

上什么也没显示

enter image description here

这是我的index.html

 <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
  <title>Apexx Portal</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link href="//netdna.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <!-- material icons import-->
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body style="margin: 0px">
  <app-root></app-root>
</body>
</html>

请告知我是否需要其他与​​之相关的信息

1 个答案:

答案 0 :(得分:0)

我认为您得到的错误是因为您没有像这样在angular.json文件中定义正确的路径:

SAMPLE ANGULAR.JSON SNIPPET

"options": {
            "outputPath": "dist",
            "index": "src/index.html",   //Define your main,runtime,polyfills routes here
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico",
              "src/manifest.webmanifest"
            ],
            "styles": [
              "src/styles.css",
              "node_modules/bootstrap/scss/bootstrap.scss",
              "src/assets/scss/paper-dashboard.scss",
              "node_modules/ngx-toastr/toastr.css",
              "node_modules/bootstrap/dist/css/bootstrap.css",
              "node_modules/font-awesome/css/font-awesome.min.css"
            ],
            "scripts": [
              "node_modules/bootstrap/dist/js/bootstrap.js"
            ]
          },

更新文件后,再次执行--prod构建,然后部署它。