我的 Angular 项目 .war 未部署在 Tomcat/Payara 服务器中

问题描述 投票:0回答:1

我在这个项目中使用 Payara Server(我认为与 Glassfish 类似)。我需要在我的 Maven 项目中添加一个前端并在该服务器中部署战争。由于不行,我在Tomcat中尝试了一下,但得到了同样的结果。

我按照 Payara 的后续步骤操作:

  1. 我放入了 Angular package.json“build”:

    “ng build --prod --base-href = ./”

(事实是,我尝试了很多方法来尝试使这项工作有效,例如将 . 替换为我的战争名称,或者在最后添加一个“/”)。

  1. 结果dist是:dist/Georreferenciacion/ 我只复制Georreferenciacion里面的内容。 (Georreferenciacion 是我的角度项目的名称),

  2. 我将所有内容都拉入:paginacion\src\main esources\static(paginacion是maven项目的名称)

  3. 我使用 mvn 命令:clean 和 package。结果是paginacion.war

  4. 我执行了payara服务器。在管理模块中,我部署了结果战争。(我在最后放了一个图像)

  5. 在我的路线中,我的角度项目应该出现在路线中:http://localhost:8080/paginacion/,但它只读取index.html而不执行脚本。战争没有错误,因为maven项目中的API运行良好。

在 Tomcat 中也是同样的步骤,同样的问题。不同的是我全部上传到 \src\main\webapp

在这两种情况下,控制台中的错误都是:

     GET http://localhost:8080/runtime.b9c754ff026a3181.js net::ERR_ABORTED 404 (Not Found)
paginacion/:13 
       GET http://localhost:8080/main.a3e20b2c30df8309.js net::ERR_ABORTED 404 (Not Found)
paginacion/:13 
       GET http://localhost:8080/polyfills.a04e0f6c8019e826.js net::ERR_ABORTED 404 (Not Found)
paginacion/:10 
       GET http://localhost:8080/styles.87eeefc8291f116b.css net::ERR_ABORTED 404 (Not Found)

我的 Angular 项目中的 index.html 是下一个:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>PgoReepClienteWeb</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="">
  <app-root></app-root>
</body>
</html>

我观看下一个教程视频:https://youtu.be/Gkkj3qMn2yE?si=ISVpL4IPe29qcvlN

angular maven tomcat deployment glassfish
1个回答
0
投票

好的,我找到解决方案了。

我将战争的名称放在index.html内的“base href”中

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>PgoReepClienteWeb</title>
  <base href="/paginacion/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="">
  <app-root></app-root>
</body>
</html>

我还放置了下一个href:

“ng build --prod --base-href /paginacion/”

© www.soinside.com 2019 - 2024. All rights reserved.