I have images in source folder of a maven java project. you can see it in the below image.
if i run install command of maven, when i see generated jar file , i could not see the images in sources in the jar file.
My maven configuration is like below.
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
How can i add images in source folder to jar file for my maven java project ?
You can use the resources plugin to add those files into your JAR. By default, Maven will look for your project's resources under src/main/resources
. So if you move your images there, they should be automatically included. However, if you want to include a different folder, you can tell Maven with:
<project>
...
<build>
...
<resources>
<resource>
<directory>[your folder here]</directory>
<includes><include>*.png</include></includes>
</resource>
</resources>
...
</build>
...
</project>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.