Создание Uberjar с вложенными ресурсами - PullRequest
1 голос
/ 23 октября 2019

Я создал uberjar для проекта с вложенными ресурсами. Поэтому в папке src / main / resources есть подпапки. Когда я пытаюсь получить доступ к любому из этих ресурсов в программе через getResourceAsStream («имя файла»), он не может найти ни один из них, если я не предоставлю полный путь к ним внутри вызова или не поместу их все в корень фляги,Есть ли способ добавить их в classpath?

Вот моя запись в pom.xml для сборочного плагина, который я использую для сборки uberjar:

<plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>build-first</id>
                    <configuration>
                        <appendAssemblyId>false</appendAssemblyId>
                        <archive>
                            <manifest>
                                <mainClass>com.joy.hmi.core.HMIApplication</mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <finalName>HMIApp</finalName>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <mainClass>com.joy.hmi.core.HMIApplication</mainClass>
                            </manifest>
                            <manifestEntries>
                                <Class-Path>images/ config/ properties/ controlTidxConfig/ HMITidxConfig/</Class-Path>
                                <Trusted-Library>true</Trusted-Library>
                                <Permissions>all-permissions</Permissions>
                                <Codebase>*</Codebase>
                                <Trusted-Only>true</Trusted-Only>
                            </manifestEntries>
                        </archive>
                    </configuration>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
                <execution>
                    <id>make-the-zip</id>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                    <finalName>HMIApp</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...