第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從maven中的外部jar復制資源?

如何從maven中的外部jar復制資源?

元芳怎么了 2021-09-29 10:39:44
我有一個基于 maven 的多模塊項目,其模塊結構如下:-- --A   pom.xml --B   pom.xml-pom.xml我在父.pom 文件中添加了一個依賴項?,F(xiàn)在我想使用來自A模塊中添加的依賴項的資源。有沒有辦法使用 maven僅將外部資源復制到A模塊?我嘗試為此使用maven-remote-resources-plugin,但它沒有看到外部資源。
查看完整描述

3 回答

?
寶慕林4294392

TA貢獻2021條經(jīng)驗 獲得超8個贊

所以我找到了下一個解決方案。它不是最佳的,但它可以工作并且可以做我想要的。它從外部 jar(maven 依賴)中提取資源文件并將其復制到類路徑資源中。


這不是最佳選擇,因為我必須在文件移動到所需位置后刪除空目錄。


<build>

        <plugins>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-dependency-plugin</artifactId>

                <version>3.1.1</version>

                <executions>

                    <execution>

                        <id>unpack</id>

                        <phase>generate-sources</phase>

                        <goals>

                            <goal>unpack</goal>

                        </goals>

                        <configuration>

                            <artifactItems>

                                <artifactItem>

                                    <groupId>com.group.id</groupId>

                                    <artifactId>artifact-id</artifactId>

                                    <version>${version}</version>

                                    <type>jar</type>

                                    <overWrite>false</overWrite>

                                    <includes>**/frontend/*.json</includes>

                                </artifactItem>

                            </artifactItems>

                            <outputDirectory>${project.build.directory}/classes/i18n</outputDirectory>

                            <overWriteReleases>true</overWriteReleases>

                            <overWriteSnapshots>false</overWriteSnapshots>

                            <overWriteIfNewer>true</overWriteIfNewer>

                        </configuration>

                    </execution>

                </executions>

            </plugin>

            <plugin>

                <groupId>com.coderplus.maven.plugins</groupId>

                <artifactId>copy-rename-maven-plugin</artifactId>

                <version>1.0</version>

                <executions>

                    <execution>

                        <id>copy-and-rename-file</id>

                        <phase>generate-sources</phase>

                        <goals>

                            <goal>rename</goal>

                        </goals>

                        <configuration>

                            <sourceFile>${project.build.directory}/classes/i18n/META-INF/resources/i18n/frontend

                            </sourceFile>

                            <destinationFile>${project.build.directory}/classes/i18n/frontend/

                            </destinationFile>

                        </configuration>

                    </execution>

                </executions>

            </plugin>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-antrun-plugin</artifactId>

                <version>1.8</version>

                <executions>

                    <execution>

                        <phase>generate-sources</phase>

                        <goals>

                            <goal>run</goal>

                        </goals>

                        <configuration>

                            <target>

                                <delete dir="${project.build.outputDirectory}/i18n/META-INF" includeemptydirs="true"/>

                            </target>

                        </configuration>

                    </execution>

                </executions>

            </plugin>

        </plugins>

    </build> 



查看完整回答
反對 回復 2021-09-29
?
月關寶盒

TA貢獻1772條經(jīng)驗 獲得超5個贊

您必須向應該使用它的模塊添加依賴項。然后你可以使用maven 依賴插件從該依賴中獲取資源。


查看完整回答
反對 回復 2021-09-29
  • 3 回答
  • 0 關注
  • 192 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號