Javascript 如何将angular 8项目构建为.war文件

Javascript 如何将angular 8项目构建为.war文件,javascript,java,angular,maven,user-interface,Javascript,Java,Angular,Maven,User Interface,我想知道如何构建angular app to.war文件,以便使用maven部署到WAS服务器 Root/ - Web resources. WEB-INF/ - directory for application support lib/ - supporting jar files web.xml - configuration file for the application 将html、js和css文件放在war文件的根目录中,该文件将用作web资源

我想知道如何构建angular app to.war文件,以便使用maven部署到WAS服务器

Root/ - Web resources.
    WEB-INF/ - directory for application support
       lib/ - supporting jar files
       web.xml - configuration file for the application

将html、js和css文件放在war文件的根目录中,该文件将用作web资源。您可以忽略WEB-INF/lib文件夹,因为angular不需要任何java库

您可以尝试使用grunt进行角度grunt构建。
请参阅

您可以通过创建用于执行angular应用程序构建的构建插件来使用maven执行此操作。 构建插件将在构建期间执行,它们应该在POM的元素中配置


    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>install</phase>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm build</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>install</phase>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>build</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


org.codehaus.mojo
execmaven插件
npm安装
执行官
安装
npm
安装
npm构建
执行官
安装
npm
跑
建造
对于您来说,重要的是之前已经安装了节点js、npm。如果没有,maven构建将失败,因为它不会发现环境需要运行angular app的构建

之后,我们修改maven-war插件。我们在下面指定的目录将是maven build生成的war中的location angular app

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <webResources>

                        <resource>
                            <targetPath>resources</targetPath>
                            <filtering>false</filtering>
                            <!-- this is relative to the pom.xml directory -->
                            <directory>../path when you want to put angular app /dist/</directory>
                            <includes>
                                <include>**/*.*</include>
                            </includes>
                        </resource
                    </webResources>
                </configuration>
            </plugin>

org.apache.maven.plugins
maven战争插件
假的
资源
假的
../path当您要放置角度应用程序/dist时/
**/*.*

是否可以从我的代码编辑器本身构建war文件?是否有任何命令!!你应该使用像maven或gradle这样的构建工具来构建war文件,这将是很容易实现的。你能帮我提供maven构建的链接吗