Java 在maven项目中添加angular作为maven模块
我在多maven项目中工作,该项目分为以下模块:Java 在maven项目中添加angular作为maven模块,java,angular,maven,Java,Angular,Maven,我在多maven项目中工作,该项目分为以下模块: 休息层 服务层 存储库层 我想添加另一个名为view layer的模块,即应用程序的ui。唯一的问题是ui是有角度的,我需要在maven模块中为这个项目集成angular应用程序 我创建了一个名为view layer的新maven模块。添加了如下视图层的插件it maven模块pom,如下所示: <plugin> <groupId>com.github.eirslett</groupId>
- 休息层
- 服务层
- 存储库层
<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>
com.github.eirslett
前端maven插件
1.3
v8.11.3
6.3.0
src/main/web/
安装节点和npm
安装节点和npm
npm安装
npm
npm运行构建
npm
运行构建
戳
npm
运行脚本生成
产生资源
并在视图模块的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>
UTF-8
UTF-8
真的
org.codehaus.mojo
execmaven插件
npm安装
执行官
安装
npm
安装
npm构建
执行官
安装
npm
跑
建造
接下来,我删除了我创建的模块中的所有内容,只留下pom文件。我删除了创建Maven模块时创建的src文件夹、测试文件夹等
之后,我使用angular CLI创建了一个新的angular应用程序。我将angular应用程序的所有内容(src、dist、nodes\u模块等)移动到maven模块项目中
最后,为了检查一切是否正常,我运行了一个maven build to parent maven项目,看看是否一切都编译成功。我认为您的
<workingDirectory>src/main/web/</workingDirectory>
src/main/web/
未更正,因为您尚未添加模块名称
像这样
<workingDirectory>frontend-module/src/main/web/</workingDirectory>
前端模块/src/main/web/
这就是为什么它无法获取您的包。json这假设所有运行此版本的计算机上都安装了node和npm(以正确的版本),这是非常脆弱的。OP使用的前端maven插件将自动下载并使用指定版本的node和npm。因此,为exec maven插件放弃前端maven插件会降低构建在机器之间的可移植性,顺便说一句,对于解决OP的问题来说完全没有必要。是的,这是真的,要使此解决方案起作用,需要已经安装节点js和npm。我认为这是更好的方法,因为您可以在自述文件中指定所需的node js和npm的版本,并且开发人员可以下载正确版本的node js。在我的团队中,我使用了这种方法,在nvm的帮助下,我们从未遇到过任何问题。您是否检查过
package.json
确实位于src/main/web/package.json
(而不是src/main/web/yourproject/package.json
?