我正在尝试将 Angular 应用程序部署到 WeblogicApplication 服务器中。
不幸的是,这不起作用。
我所做的是:
1)构建我的 Angular 应用程序(exec-maven-plugin)并将结果放入“/dist”文件夹中
2)构建包含“/dist”文件夹的WAR文件(maven-war-plugin)
这样我就有了一个普通的 War 文件,其中的 dist 文件夹位于根级别(没有 xml 文件)。
3)使用以下命令构建 EAR 文件(maven-ear-plugin):
<modules>
<webModule>
<groupId>com.example.test</groupId>
<artifactId>angular-app</artifactId>
<contextRoot>angular-app</contextRoot>
</webModule>
</modules>
所以我得到了一个包含 war 文件和 application.xml 的 EAR 文件:
<module>
<web>
<web-uri>angular-app-1.0.0-SNAPSHOT.war</web-uri>
<context-root>angular-app</context-root>
</web>
</module>
但是当我尝试打开应用程序时,我只看到“未找到”页面或“错误 404 - 未找到” 无论什么网址:
hostname:8080/angular-app/dist/index.html
hostname:8080/dist/index.html
或其他组合
我需要做什么才能使 Angular 应用程序可用?
编辑:首先我通过 SCP 将文件复制到服务器,然后通过 Web 控制台部署该文件。
确保您使用 base-href 和 deploy-url 参数 对于你的情况来说是
ng build --base-href /angular-app/ --deploy-url /angular-app/
在dist//文件夹内创建WEB-INF文件夹 在 WEB-INF 文件夹中创建 web.xml 和 weblogic.xml 使用标准约定
1. create a empty spring boot project with war configuration and use the below code to copy dist folder of anugalr app.
deploy the war to weblogic.
<build>
<finalName>WarName</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>dist/npr</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>