Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用嵌套资源创建uberjar_Java_Maven_Maven Assembly Plugin - Fatal编程技术网

Java 使用嵌套资源创建uberjar

Java 使用嵌套资源创建uberjar,java,maven,maven-assembly-plugin,Java,Maven,Maven Assembly Plugin,我已经为一个包含嵌套资源的项目创建了一个uberjar。因此在src/main/resources文件夹中有子文件夹。当我试图通过getResourceAsStream(“文件名”)访问程序中的任何资源时,都无法找到它们,除非我在调用中提供它们的完整路径,或者将它们全部放在jar的根目录下。有没有办法将这些添加到类路径中 下面是我用于构建uberjar的汇编插件的pom.xml条目: <plugin> <artifactId>maven-assem

我已经为一个包含嵌套资源的项目创建了一个uberjar。因此在src/main/resources文件夹中有子文件夹。当我试图通过getResourceAsStream(“文件名”)访问程序中的任何资源时,都无法找到它们,除非我在调用中提供它们的完整路径,或者将它们全部放在jar的根目录下。有没有办法将这些添加到类路径中

下面是我用于构建uberjar的汇编插件的pom.xml条目:

<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>

maven汇编插件
2.4
先建
假的
com.joy.hmi.core.hmi应用程序
带有依赖项的jar
HMIApp
真的
com.joy.hmi.core.hmi应用程序
image/config/properties/controlTidxConfig/hmitdxconfig/
真的
所有权限
*
真的
包裹
单一的
拉拉链
单一的
包裹
HMIApp
假的
src/main/assembly/assembly.xml