maven實現compile時將資源目錄輸出到target中


由於現在項目采用的是 jboot 框架,升級最新版本2.1.5后,需要將原來的webroot資源改到 src/main/webapp目錄下,

發現轉移后,通過框架的app.java入口main函數無法將新增過來的webapp資源更新到target/classes下面,

所以用下面maven配置文件 可以有效解決。

<plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/classes/webapp</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/../jyb_project/src/main/webapp</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

上面的  resources 是欲拷貝的目錄, outputDirectory是目標目錄。

------------------------------------------------------------------------------

這個maven流弊之處在於 支持html,等靜態資源 熱編譯,在當前改動的html下面 按下ctrl+f9或者點擊build project 可以自動將改動html平移到了target目錄下。

難道是 idea 的 build project會根據maven的配置文件的參數編譯? 反正 很流弊,記錄一下。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM