Maven资源插件从不同的路径公开图像

时间:2015-12-18 14:51:03

标签: maven maven-resources-plugin

我可以通过 /resources/gfx/loading.gif

访问immage

我想从/img/immage.gif

获取

我尝试使用以下配置 maven-resources-plugin ,但实际上没有任何反应。

我目前正在从eclipse构建应用程序。

 <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
            <execution>
                <id>copy-loading-status</id>
                <phase>package</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
                <configuration>
                    <outputDirectory>/src/main/webapp/img</outputDirectory>
                    <resources>
                        <resource>
                            <directory>/src/main/resources/gfx</directory>
                            <includes>
                                <include>loading.gif</include>
                            </includes>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>

1 个答案:

答案 0 :(得分:2)

假设您正在构建WAR,您可以配置maven-war-plugin以包含其他Web资源:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <webResources>
            <resource>
                <directory>/src/main/resources/gfx</directory>
                <includes>
                    <include>loading.gif</include>
                </includes>
                <targetPath>img</targetPath>
            </resource>
        </webResources>
    </configuration>
</plugin>