我正在開發一個帶有戰爭外部依賴項的 maven 專案(我們稱之為戰爭依賴項 WAR-DEP)
在構建之后和打包階段,我將獲取WAR-DEP的內容,并使用 maven-war 插件的覆寫功能將其與當前構建的內容合并。
在WAR-DEP中,我們的WEB-INF/lib檔案夾中有一些必需的 jar,因此通過覆寫,我們最終獲得了最終戰爭中所需的一切,但是當為我們提供WAR-DEP戰爭的專案添加了一個新的專案時,我們的問題就開始了WEB-INF/lib-new中的檔案夾,并將我們之前在WEB-INF/lib檔案夾中的一些 jar 移動到這個新檔案夾WEB-INF/lib-new中。
在使用這個新版本的WAR-DEP構建后,覆寫按預期作業,所以我們最終在 WEB-INF 中有兩個檔案夾(lib 和 lib-new),并且我們的應用程式停止作業,因為這個WEB-INF/lib-new 是Tomcat 服務器無法識別。因此,在不更改 tomcat 端的類路徑的情況下,有沒有一種方法可以在生成戰爭之前將 lib-new 的內容移動到 lib 檔案夾中?我的意思是例如在覆寫期間,但我不確定如何執行此操作。感謝您的投入。
uj5u.com熱心網友回復:
maven-war-plugin
沒有所需的功能,但maven-dependency-plugin
可能會有所幫助,smth。喜歡:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>unpack-lib-new</id>
<goals>
<goal>unpack</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>dep-group-id</groupId>
<artifactId>dep-artifiact-id</artifactId>
<version>dep-version</version>
<type>war</type>
<outputDirectory>${project.build.directory}/${build.finalName}/WEB-INF/lib</outputDirectory>
<includes>WEB-INF/lib-new/*</includes>
<fileMappers>
<org.codehaus.plexus.components.io.filemappers.FlattenFileMapper/>
</fileMappers>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
...
<overlays>
<!-- current project -->
<overlay/>
<overlay>
<id>dep-skip-lib-new</id>
<groupId>dep-group-id</groupId>
<artifactId>dep-artifact-id</artifactId>
<excludes>
<exclude>WEB-INF/lib-new/*</exclude>
</excludes>
</overlay>
</overlays>
...
</configuration>
</plugin>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/504810.html
下一篇:如何解決"Can'taccesss"\"404notfound",asPackageaspringprojectanddeployinTomcat