在 maven 中,如何在输出 jar 的同一位置包含非 java src 文件? [英] In maven how can I include non-java src files in the same place in the output jar?

查看:21
本文介绍了在 maven 中,如何在输出 jar 的同一位置包含非 java src 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了一个源代码包.在 src 目录树中有一些属性文件(.properties),我想将它们保存在输出 jar 的同一个位置.例如:我想要

I received a source code bundle. Inside the src directory tree there are some properties files(.properties) which I want to keep in the output jar in the same place. e.g: I want

src/main/java/com.mycompany/utils/Myclass.java 
src/main/java/com.mycompany/utils/Myclass.properties

在罐子里保持不变:

com.mycompany/utils/Myclass.class 
com.mycompany/utils/Myclass.properties

无需将属性文件添加到单独的资源文件夹中.有什么办法可以告诉 maven 吗?

without needing to add the properties file it to separate resources folder. Is there a way to I tell this to maven?

推荐答案

你可以在你的 pom 中添加以下内容,表明资源在 src/main/java包括 资源类型.

You could add the following in your pom indicating that the resources are available in src/main/java and including the type of resources.

<build>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.properties</include>
            </includes>
        </resource>
    </resources>
</build>

这篇关于在 maven 中,如何在输出 jar 的同一位置包含非 java src 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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