Onejar,使用maven,不会将资源复制到jar中

2024-05-16

我正在使用 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>

我究竟做错了什么?如何将资源包含在一罐子中?


我已经发现了我的错误。它把它放在罐子里,只是不在我预期的地方。它包含在主罐子内的一个罐子中。具体来说,resourceTest-0.0.1-SNAPSHOT.one-jar.jar包含resourceTest-0.0.1-SNAPSHOT.jar,其中包含我的资源。

现在我只需要找出如何访问资源,但这是另一个问题,需要进行更多研究。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Onejar,使用maven,不会将资源复制到jar中 的相关文章

随机推荐