![](/img/trans.png)
[英]Adding existing maven project to Maven multi module project in eclipse
[英]Adding angular as maven module in maven project
我在多个 maven 项目中工作,该项目分为以下模块:
我想添加另一个名为视图层的模块,即应用程序的 ui。 唯一的问题是 ui 是 angular,我需要以某种方式在这个项目的 maven 模块中集成 angular 应用程序。
我创建了一个名为视图层的新模块 maven。 添加了以下插件 maven 视图层的模块 pom,如下所示:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
<workingDirectory>src/main/web/</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
并在视图模块的 src/main/web 目录中生成一个带有 angular cli 的 angular 应用程序。 不幸的是构建失败,它没有找到 package.json。
我将不胜感激任何帮助。
问候,达斯巴托。
我这样做是为了在多 maven 项目中将 angular 添加为 maven 模块。
首先,我通过跳过原型选择来添加一个简单的 maven 模块。 我通过添加以下配置来修改pom:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<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>
接下来,我删除了我创建的模块中的所有内容,只留下 pom 文件。 我删除了创建 Maven 模块时创建的 src 文件夹、测试文件夹等。
之后,我使用 ANGULAR CLI 创建了一个新的 angular 应用程序。 我将 angular 应用程序(src、dist、nodes_modules 等)的所有内容移动到 maven 模块项目。
最后,为了检查是否一切正常,我运行了一个 maven 构建到父项目 maven 以查看是否一切都编译成功。
我认为你的
<workingDirectory>src/main/web/</workingDirectory>
不正确,因为您还没有添加模块名称
像这样
<workingDirectory>frontend-module/src/main/web/</workingDirectory>
这就是为什么它无法获取您的 package.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.