如何解决为什么bazel将资源从子目录复制到jar的顶层
因此,BUILD结构如下:
java:
/src/java/com/abc/code/Code.java
资源:
/src/resources/com/abc/code/application.properties
已建立文件组
filegroup(
name = "properties",srcs = glob(["application.properties"])
visibility = ["//visibility:public"],)
已构建应用 使用文件组作为资源/ classpath_resources
java_binary(
name = "app",classpath_resources = [
"//src/resources/com/abc/code:properties",],# resources = [
# "//src/resources/com/abc/code:properties",# ],main_class = "com.abc.code.Code",runtime_deps = [
":app_bin",)
取回null
的{{1}}
,然后检查生成的jar,发现application.properties位于顶部的Code.class.getResourceAsStream("application.properties");
/
jar tf poc_delivery_system_app.jar
然后将代码更新为有效的META-INF/
META-INF/MANIFEST.MF
application.properties
,
问题是,为什么Code.class.getResourceAsStream("/application.properties");
位于顶层而不是application.properties
解决方法
资源具有以下资源
var persons = [
{name: "Alex",age:22},{name: "Maria",age:30}
]
var number = 0;
for (var i = 0; i < persons.length; i++) {
console.log(persons[i].name);
console.log(persons[i].age);
console.log("----------------");
console.log(number)
};
while(number < 5) {
console.log(number);
number += 1;
};
所以,确实是源头。
如果要将它们放在子目录中,请使用
将BUILD文件放置在srcs = glob(["application.properties"])
上
$WORKSPACE/src/resources/BUILD
然后Java库将
filegroup(
name = "resources",srcs = glob(["**/*.properties"]),)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。