Java 无法使用maven运行npm grunt bower

Java 无法使用maven运行npm grunt bower,java,angularjs,node.js,maven,gruntjs,Java,Angularjs,Node.js,Maven,Gruntjs,我有一个使用npm bower和grunt的简单web应用程序。我将此项目用作maven项目中的一个模块。我搜索了互联网,找到了如何为项目定义pom.xml,但我无法运行它。有谁能告诉我如何使用maven构建和运行webapp的步骤吗 pom.xml文件 <build> <plugins> <plugin> <groupId>org.codehaus.mojo</grou

我有一个使用npm bower和grunt的简单web应用程序。我将此项目用作maven项目中的一个模块。我搜索了互联网,找到了如何为项目定义pom.xml,但我无法运行它。有谁能告诉我如何使用maven构建和运行webapp的步骤吗

pom.xml文件

<build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.5.0</version>
                <executions>
                    <execution>
                        <id>exec-npm-install</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                        </configuration>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>exec-bower-install</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <executable>bower</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                        </configuration>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>exec-grunt</id>
                        <phase>process-resources</phase>
                        <configuration>
                            <executable>grunt</executable>
                        </configuration>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

如何使用maven构建和运行这个pom

无法运行它的原因是,它不是可执行文件,如果不在windows上,它是批处理文件或shell脚本

您仍然可以使用maven exec插件来运行它。但是,要做到这一点,您必须将批处理文件
npm
提供给
cmd
程序(或
bash
或您最喜欢的shell)

以下是您需要进行的更改

将批处理馈送到cmd的实际命令

cmd /c "npm --version"
以下是插件配置中的更改

<configuration>
  <executable>cmd</executable> <!-- or bash -->
  <workingDirectory>./</workingDirectory>
  <arguments>
    <argument>/c</argument>
    <argument>"npm --version"</argument>
  </arguments>
</configuration>

指令
./
/c
“npm--版本”

这应该可以工作。

无法运行它的原因是它不是可执行文件,如果不在windows上,它是批处理文件或shell脚本

您仍然可以使用maven exec插件来运行它。但是,要做到这一点,您必须将批处理文件
npm
提供给
cmd
程序(或
bash
或您最喜欢的shell)

以下是您需要进行的更改

将批处理馈送到cmd的实际命令

cmd /c "npm --version"
以下是插件配置中的更改

<configuration>
  <executable>cmd</executable> <!-- or bash -->
  <workingDirectory>./</workingDirectory>
  <arguments>
    <argument>/c</argument>
    <argument>"npm --version"</argument>
  </arguments>
</configuration>

指令
./
/c
“npm--版本”
这应该行得通