java - 没有资源的 jar 应该如何工作?(排除资源的 maven-shade-plugin)
问题描述
我有一个没有任何文档的遗留代码(假设是 100% 工作)。这段代码由几个独立的服务组成,它们执行一些任务(比如使用 RabbitMQ,将一些记录插入 Postgres DB,等等)。maven-shade-plugin 配置中 pom.xml 中的每个服务都具有从生成的 jar 中排除的资源文件夹。像这样:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin-version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>log4j2.xml</exclude>
<exclude>application.properties</exclude>
<exclude>update.sql</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
结果,当我尝试运行任何这样的 jars ( with java -jar any_of_my_jars.jar
) 时,它们会失败,因为它们需要 application.properties 和所有其他资源才能运行。
所以问题是:应该是我错过了一些东西。我要么应该以其他方式运行它们,要么应该将它们部署在某个地方。有人可以向我解释一下这些罐子如何用作工作罐子吗?
解决方案
推荐阅读
- android - 即使在应用程序被杀死后如何缓存数据一段时间?
- javascript - 如何设置picker的边框
- python - tensorflow中是否有类似的代码torch.backends.cudnn.benchmark/torch.cuda.synchronize()?
- scala - 如何添加字段以便稍后为 graphQL 定义与 Sangria 的关系?
- excel - VBA 宏比较日期取最早
- c++ - 读取访问冲突。_Mycont 为 nullptr
- javascript - 如何在本机反应中关闭或关闭警报框...?
- node.js - 如何验证恶意输入?
- kotlin - kotlin 中 '=lazy' 之间的 'by lazy' 有什么区别?
- javascript - 仅使用属性访问器(点表示法或括号表示法),如何直接设置未定义的嵌套属性?