简体   繁体   English

在哪里定义服务器端jar的类路径? manifest.mf与CLI参数-cp

[英]Where to define the classpath for server side jars ? manifest.mf versus CLI argument -cp

Realized a similar question was posted earlier but had no answers. 意识到较早发布了类似问题,但没有答案。 Uuse both a manifest.mf and also pass jars using cp? 既要使用manifest.mf文件,也要使用cp传递jar?

  1. What is the best way to define classpath in java batch environment? 在Java批处理环境中定义类路径的最佳方法是什么? Can both Manifest.MF and cp argument via Command line be used or Do one override the other or Do one takes precedence over the other? 可以同时使用通过命令行的Manifest.MF和cp参数,还是可以使用一个优先于另一个?

  2. If I am using JavaEE-API jar instead of the actual JMS* and XML* jars which are available on the server. 如果我使用JavaEE-API jar,而不是服务器上可用的实际JMS *和XML * jar。 Do I need to include each individual jar in the build.gradle as "runtime" ? 我是否需要在build.gradle中将每个jar都包含为“运行时”? for traceability on the actual dependencies? 实际依赖项的可追溯性? What would be the best practice? 最佳做法是什么?

  3. Taking Continuous integration into account, should the server side dependency jars be packaged along with the application jar, so that its a standalone app ?! 考虑到持续集成,应该将服务器端依赖项jar与应用程序jar一起打包,以使其成为独立的应用程序吗?

Thank you, 谢谢,

What is the best way to define classpath in java batch environment ? 在Java批处理环境中定义类路径的最佳方法是什么? Can both Manifest.MF and cp argument via Command line be used or Does one override the other or Does one takes precedence over the other ? 可以同时使用通过命令行的Manifest.MF和cp参数吗?是否可以覆盖另一个?还是可以优先于另一个?

Nowadays, it's common to create an uber jarfile, one that includes all of its dependencies together, and then to create an executable jar , which leverages the manifest file. 如今,通常会创建一个uber jarfile(一个将其所有依赖项都包括在内),然后创建一个可执行jar来利用清单文件。

To be clear, if you use the -cp command line option, you still need to specify the class to call containing your application entry point, ie the class containing public static void main(String[] args) . 为了清楚-cp ,如果使用-cp命令行选项,则仍需要指定包含应用程序入口点的要调用的类,即,包含public static void main(String[] args)

If I am using javaee-api jar instead of the actual jms* and xml* jars which are available on the server. 如果我使用的是javaee-api jar而不是服务器上可用的实际jms *和xml * jar。 Do I need to include each individual jar in the build.gradle as "runtime" ? 我是否需要在build.gradle中将每个jar都包含为“运行时”? for tracebility on the actual dependencies ? 对于实际依赖项的可追溯性? What would be the best practice ? 最佳做法是什么?

The better scope to use here is provided , since these libraries will be provided for you by the container. 是更好的范围,在这里使用provided ,因为这些库将由容器提供给你。

Taking Continuous integration into account, should the server side dependency jars be packaged along with the application jar, so that its a standalone app ?! 考虑到持续集成,应该将服务器端依赖项jar与应用程序jar一起打包,以使其成为独立的应用程序吗?

This is a very common practice now, and it simplifies deployment because all dependencies are bundled together. 现在这是非常普遍的做法,并且由于所有依赖项都捆绑在一起,因此可以简化部署。 This is the approach that the Dropwizard web service framework has taken, using Jetty as an embedded container. 这是Dropwizard Web服务框架采用的方法,它使用Jetty作为嵌入式容器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM