如何使用Maven启动“bower install”,然后“spring-boot:run”?
问题描述:
我是一名研究人员,在我的项目中,我对Maven没有什么了解。如何使用Maven启动“bower install”,然后“spring-boot:run”?
我在同一个存储库中使用spring-boot和angular 1,我需要一个解决方案在使用maven插件“spring-boot:run”之前首先执行“bower install”。
我想知道是否可以自定义maven命令。
我用的IntelliJ和所有我能做的就是在我的主类按下启动按钮
package fr.studionline;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableAutoConfiguration
public class StudionlineBackApplication {
public static void main(String[] args) {
SpringApplication.run(StudionlineBackApplication.class, args);
}
}
的bower_components目录是在另一个目录比主类,如下面的图片描述: tree view of my project
如果您能帮助我了解它的工作原理,请事先致谢。
如果在我的问题中缺少某些内容,我会回复任何问题。
UPDATE:
我曾尝试前端Maven的这个POM配置撑着:
<build>
<resources>
<resource>
<directory>src/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- Use the latest released version:
https://repo1.maven.org/maven2/com/github/eirslett/frontend-maven-plugin/ -->
<version>1.4</version>
<executions>
<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
</executions>
<configuration>
<workingDirectory>src/main/resources/static</workingDirectory>
</configuration>
</plugin>
</plugins>
</build>
,这是发生了什么,当我执行命令前端:凉亭
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building studionline-back 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- frontend-maven-plugin:1.4:bower (default-cli) @ studionline-back ---
[INFO] Running 'bower install' in C:\Antoine\Ecole\Projet\ProjetAnu_5A\studionline-back\src\main\resources\static
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.071 s
[INFO] Finished at: 2017-07-06T17:59:58+02:00
[INFO] Final Memory: 11M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-
plugin:1.4:bower
(default-cli) on project studionline-back: Failed to run task: 'bower install' failed.
java.io.IOException:
Cannot run program "C:\Antoine\Ecole\Projet\ProjetAnu_5A\studionline-back\src\main\resources\static\node\node.exe"
(in directory "C:\Antoine\Ecole\Projet\ProjetAnu_5A\studionline-back\src\main\resources\static"):
CreateProcess error=2, Le fichier spécifié est introuvable -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Process finished with exit code 1
但我仍然不明白如何使用Intellij启动它。我应该做mvn而不是点击“运行”按钮吗?
答
看看frontend-maven-plugin
。特别是它有一个bower runner。
<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<!-- optional: The default argument is actually
"install", so unless you need to run some other bower command,
you can remove this whole <configuration> section.
-->
<arguments>install</arguments>
</configuration>
</execution>
检查“可选配置”部分以了解如何配置您的前端目录。在你的情况下:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- optional -->
<configuration>
<workingDirectory>src/main/resources/static</workingDirectory>
</configuration>
</plugin>
Thx我会立即尝试 – ashalaya