我正在尝试根据构建时选择的配置文件将图像添加到我的Maven Web应用程序中。但我继续将所有配置文件的整个文件夹放到我需要图像的位置。
src/main/profile/webapp/
如何解决这个问题?默认图像为user
,两个配置文件的各个图像的顺序正确。在dev
内,有2个文件夹banner.jpg
和{{1}},每个文件夹都有图片文件夹和{{1}}图片内部文件夹。
答案 0 :(得分:2)
您需要在每个配置文件中定义一个自定义属性,然后在插件的配置中引用该属性:
<build>
<finalName>user-interface</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<webResource>
<directory>src/main/profile/webapp/${banner.folder}</directory>
<targetPath>images</targetPath>
</webResource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>user</id>
<properties>
<banner.folder>user</banner.folder> <!-- defines banner.folder property when the user profile is activated -->
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<banner.folder>dev</banner.folder> <!-- defines banner.folder property when the dev profile is activated -->
</properties>
</profile>
</profiles>