【发布时间】:2017-08-02 08:59:47
【问题描述】:
我的 Spring-boot 项目结构如下
-Project
- src
- main
- java
- resources
- webapp
- test
- frontend
- src
- static
- config
- package.json
- (after "npm install") node_modules
- (after "npm run build") dist
我想做的是
安装项目后,运行“npm install”
当“spring-boot:run”运行时,运行“npm run build”并将front/dist中的内容移动到/main/webapp
这是我的 pom.xml
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>exec-npm-install</id>
<phase>generate-sources</phase>
<configuration>
<executable>npm</executable>
<workingDirectory>./frontend</workingDirectory>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
我不知道如何触发 exec-npm-install 执行 使用 Eclipse maven 构建,我尝试了 generate-sources、spring-boot:run、安装和编译、打包但它没有运行。
我想知道我应该放什么命令,在“spring-boot:run”时移动dist
【问题讨论】:
-
您需要将其移出插件管理区域。在 pluginManagement 中,您可以定义版本和参数,但您需要将其放在 pluginManagement 之外。
-
谢谢。在Eclipse中,没有pluginManagement,执行会出现错误信息,所以我把它们放在里面。现在,正如您的评论,我删除了 pluginManagement 并忽略了执行错误。它有效!
-
你得到什么样的执行错误?
标签: maven spring-boot exec-maven-plugin