我正在使用one-jar打包我的程序。我在src/main/resources中有资源。maven- resources -plugin正确地将资源复制到jar中,但是onejar生成的jar不包含我的资源。
这是我的pom:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ziroby</groupId>
<artifactId>resourceTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>resourceTest</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.dstovall</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<configuration>
<attachToBuild>true</attachToBuild>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>onejar-maven-plugin.googlecode.com</id>
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginRepository>
</pluginRepositories>
</project>我做错了什么?如何在one-jar中包含资源?
发布于 2011-04-17 04:08:04
我发现了我的错误。它是把它放在罐子里,只是不在我期望的地方。它被装在主罐子里的罐子里。具体地说,resourceTest-0.0.1-SNAPSHOT.one-jar.jar包含resourceTest-0.0.1-SNAPSHOT.jar,其中包含我的资源。
现在我只需要找出如何访问资源,但这是另一个问题,这需要更多的研究。
发布于 2017-08-03 12:31:40
如果您使用的内容类似于:getClass().getClassLoader().getResourceAsStream
请尝试使用:Thread.currentThread().getContextClassLoader().getResourceAsStream
https://stackoverflow.com/questions/5688329
复制相似问题