Maven 资源插件从不同路径公开图像
Maven resource plugin expose an image from a different path
我有一张图片可以从 /resources/gfx/loading.gif
访问
我想让从/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>
假设您正在构建 WAR,您可以配置 maven-war-plugin
以包含其他网络资源:
<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>
我有一张图片可以从 /resources/gfx/loading.gif
访问我想让从/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>
假设您正在构建 WAR,您可以配置 maven-war-plugin
以包含其他网络资源:
<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>