I saw How do I load a file from resource folder? and that is for that is programmatically getting the resource and I don't face any issue when I run the code locally.
I am facing a weird issue. I have a Runner file which looks at the files present at - src/main/resources
. Runner works fine if I run it standalone, but when I make a jar and try to run the jar it could not locate the files in src/main/resources
.
When I run
java -jar Java_Project.jar
then I get error:
Jul 05, 2022 10:17:17 AM com.aventstack.extentreports.config.external.XmlConfigLoader createStream
SEVERE: src\main\resources\extent-config.xml
java.io.FileNotFoundException: src\main\resources\extent-config.xml (The system cannot find the path specified)
Build section of POM.xml looks like
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<includes>
<include></include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${maven.surefire.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>
Runner
</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Any solution or pointer is appreciated.