关于java:如何在Maven构建中包含资源文件夹 | 珊瑚贝

How to include folder with resource in Maven build


我在文件夹中有一个机器人资源文件,当我执行Maven安装时,要包含文件夹和机器人资源文件。

这是项目结构:

项目>文件夹>机器人资源文件

项目 > src > main > java …

在我的 pom.xml 文件中,我添加了:

1
2
3
4
5
6
7
8
<resources>
    <resource>
        <directory>/Project/Folder</directory>
        <includes>
            <include>**/*.robot</include>
        </includes>
    </resource>
</resources>

当我执行 Maven 安装时,我只看到 jar 中的机器人资源文件,但看不到它的文件夹。如何使机器人资源文件在文件夹中进行?我是maven的新人,所以我很欣赏任何指导。我已经看到了这个参考,但这并不是提供答案:http://maven.apache.org/plugins-archives/maven-resources-plugin-2.6/examples/resource-directory.html

谢谢!

  • 你试过了吗:<directory>文件夹</directory>
  • 是的,我做到了,并且该文件夹也不存在于 jar 中。
  • 最好的是将它放入 src/main/resources 包括目录中,就是这样……


为什么不包括文件夹?

首先,<directory> 查看指定的文件夹,但不包括文件夹本身。其次,项目根目录的符号不是Project,而是${project.basedir}.

建议的解决方案

指定一个比您要包含的目录高一级的目录。

1
2
3
4
5
6
7
8
<resources>
    <resource>
        <directory>${project.basedir}</directory>
        <includes>
            <include>**/*.robot</include>
        </includes>
    </resource>
</resources>
  • 我刚试过这个,jar也不包含文件夹。 (还是)感谢你的建议。


来源:https://www.codenong.com/47445080/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9965.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?