Spring-Boot-Ressource bei Verwendung von ausführbarem Jar @ nicht gefund

wieder stelle ich ein merkwürdiges Problem gegenüber und hoffe, dass jemand hier helfen kann.

Ich habe ein Spring-Boot-Backend-Modul, was in Eclipse gut funktioniert und die Anwendung kann beim Starten von main in application.java ausgeführt werden. Alles ist gut

Meine Anwendung importiert Beispieldaten in die Datenbank mithilfe von CSV-Dateien, die im Ordner "src / main / resources" enthalten sind. Wie bereits erwähnt, funktioniert beim Start in Eclipse alles.

Nun möchte ich es als ausführbares jar ausführen, die Anwendung wird gestartet und kann dann nicht gestartet werden, da die csv-Dateien nicht gefunden werden können. Der Pfad, den es ausgibt, wo es nach den Dateien gesucht hat, ist korrekt und die CSV-Dateien sind im Jar enthalten.

Der Pom des Moduls sieht folgendermaßen aus:

<project>
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>at.company.bbsng</groupId>
        <artifactId>bbsng-import</artifactId>
        <version>0.1.0-SNAPSHOT</version>
    </parent>

    <artifactId>bbsng-import-backend</artifactId>
    <name>bbsng-import-backend</name>

    <properties>
        <start-class>at.company.bbsng.dataimport.Application</start-class>
    </properties>


    <dependencies>

        <!-- SPRING ... -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
            <!-- EXCLUDE LOGBACK AND USE LOG4J -->
            <exclusions>
                <exclusion>
                    <artifactId>spring-boot-starter-logging</artifactId>
                    <groupId>org.springframework.boot</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- COMMONS ... -->

        ...

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

Path to csv-files werden in Eigenschaftendateien wie folgt konfiguriert:

# EXAMPLE PATH
csv.path=config/csv/

Der Teil der Java-Konfigurationsdatei ist wie folgt:

  ...

  @Value("${csv.path}")
  private String csvExamplePath;

  @Bean
  public Resource addressResource() {
    return new ClassPathResource(csvExamplePath + CSV_ADDRESS);
  }

    ...

Im jar befinden sich die Dateien unter path

\config\csv\

Stacktrace:

Caused by: java.io.FileNotFoundException: class path resource [config/csv/Company.csv] cannot be resolved to absolute file path because it does not reside in th
e file system: jar:file:/C:/Development/Projekte/bbsng/trunk/import/backend/target/bbsng-import-backend-0.1.0-SNAPSHOT.jar!/config/csv/Company.csv
        at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:207)
        at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
        at at.compax.bbsng.dataimport.app.source.company.CompanyGenerator.init(CompanyGenerator.java:28)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java

Again, die Anwendung funktioniert wie erwartet, wenn sie von Eclipse gestartet wird. Nur ausführbare JAR-Dateien klagen über fehlende CSV-Dateien, die sich bereits in JAR befinden.

Jeder Hinweis wäre toll.

Antworten auf die Frage(3)

Ihre Antwort auf die Frage