具有Maven的Onejar不会将资源复制到jar中 [英] Onejar, with maven, won't copy resource into jar

查看:79
本文介绍了具有Maven的Onejar不会将资源复制到jar中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个jar打包程序.我在src/main/resources中有资源. maven-resources-plugin可以将资源正确复制到jar中,但是onejar生成的jar不包含我的资源.

I'm using one-jar to package up my program. I have resources in src/main/resources. The maven-resources-plugin correctly copies the resources into the jar, but the jar produced by onejar does not contain my resources.

这是我的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>

我做错了什么?如何在一个罐中包含资源?

What am I doing wrong? How do I include resources in one-jar?

推荐答案

我发现了我的错误.它正在把它放在罐子里,而不是我期望的那样.它包含在主罐中的一个罐中.具体来说,resourceTest-0.0.1-SNAPSHOT.one-jar.jar包含resourceTest-0.0.1-SNAPSHOT.jar,其中包含我的资源.

I have discovered my error. It was putting it in the jar, just not where I expected it to be. It's contained in a jar inside the main jar. Specifically, resourceTest-0.0.1-SNAPSHOT.one-jar.jar contains resourceTest-0.0.1-SNAPSHOT.jar, which contains my resource.

现在,我只需要了解如何访问资源,但这是另一个问题,需要进行更多的研究.

Now I just need to find out how to access the resource, but that's another question, which warrants more research.

这篇关于具有Maven的Onejar不会将资源复制到jar中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆