我已经使用后端的Spring Boot(v1.5.9.RELEASE)和前端的Angular 4+创建了一个应用程序。我已经设置了Maven配置,以便在编译时安装Node和NPM,构建Angular应用,复制资源,然后构建最终的可执行jar。
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>${node.version}</nodeVersion>
<npmVersion>${npm.version}</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</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>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/main/resources/static</outputDirectory>
<resources>
<resource>
<directory>dist</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.toolc.Application</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.frannetpfa.Application</mainClass>
<profiles>
<profile>aws</profile>
<profile>app_runner</profile>
</profiles>
</configuration>
</plugin>
</plugins>
<finalName>frannetpfa</finalName>
</build>
所有这些都很好,我很高兴。但是,每次开发时,我想做的就是跳过安装节点/ npm,ng-build,并在每次使用spring-boot-maven-plugin运行Spring Boot应用程序时复制资源步骤。这些步骤需要很多时间,如果我没有对前端进行任何更改,则这些步骤是不必要的。
我对Maven并没有足够的了解,只是足以使它完成我需要做的事情。我希望有一种方法可以设定目标/阶段来实现这一目标。我可以跳过测试,但是在spring-boot-maven-plugin文档中,我找不到通过命令行或pom.xml文件中的选项来跳过其他目标/阶段的方法。