我創建了一個Spring Boot應用程序,我想部署通過Yeoman(角度生成器)生成的Web前端。然而,我無法讓事情發揮作用:當我運行應用程序時,我的靜態資源被部署用於生產(localhost:8080/dist/index.html正在運行很酷),而不是用於開發(localhost:8080/app/index.html不工作很酷)。Spring Boot Maven Plugin和Grunt with live reload
我將整個web前端結構移動到static
。通過終端,我可以cd到該文件夾(src/main/resources/static
)並運行grunt build
和grunt serve
;這樣,當我在前端工作時,我可以利用實時重新加載。
然後,我創建了下面的腳本在項目的根通過咕嚕建立我的前端:
echo 'Running grunt build...'
cd src/main/resources/static
grunt build
echo 'Done running grunt'
我修改pom.xml
如下:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>Grunt build</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/runGrunt.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
現在,當我執行mvn spring-boot:run
,我的Spring項目開始正確,但是咕嚕聲是爲生產而建的(訪問app/index.html不會讓我加載角色& co)。
我怎樣才能連線的東西,這樣我可以執行mvn spring-boot:run
拿到我的前端項目編制,部署和現場重裝(即我要訪問本地主機:8080 /應用/ index.html,然後拿到角&共同加載) ?