简体   繁体   English

如何从war文件之外的另一个类中调用war文件中的一个类?

[英]How to call a class in war file from another class outside the war file?

how to call a class in war file from another class outside the war file. 如何从war文件之外的另一个类调用war文件中的类。 Iam getting problem when accessing that class from war file how to overcome that problem. 我从战争文件访问该类时遇到问题,如何克服该问题。

You don't... Unless the War refers to a jar that is in both wars... 你不会...除非战争提到两次战争中都存在的罐子...

A war is a collection of jars, as a sort of wrapper... 战争是罐子的集合,就像是包装纸一样。

So make more jars, and import those in different wars 因此,制造更多的罐子,并导入不同战争中的罐子

Try to only create classes in a War that are needed for that webservice only... Not helper classes, since they might be necessary for other applications/services 尝试仅在战争中仅创建该Web服务所需的类...而不是辅助类,因为它们对于其他应用程序/服务可能是必需的

Jar: collection of Java Classes, property files, so that a collection of classes can be ran from within a computer (Wiki on jar https://en.wikipedia.org/wiki/JAR_(file_format) ) Jar:Java类,属性文件的集合,以便可以在计算机内部运行类的集合(jar上的Wiki https://en.wikipedia.org/wiki/JAR_(file_format)

java -jar xxx.jar java -jar xxx.jar

War: Web ARchive (Wiki on war https://en.wikipedia.org/wiki/WAR_(file_format) ) 战争:网络存档(战争Wiki, https ://en.wikipedia.org/wiki/WAR_(file_format

is meant to be put inside a webserver (like Tomcat/Jetty) with has a collection of Jars, and configuration information necessary for link with internet... Like REST, JSP, Html... 旨在放置在具有Jars集合的Web服务器(例如Tomcat / Jetty)内,以及与Internet链接所需的配置信息...例如REST,JSP,HTML ...

Ear: Enterprise ARchive (wiki on ear https://en.wikipedia.org/wiki/EAR_(file_format) ) 耳朵:Enterprise ARchive(耳朵上的Wiki https://en.wikipedia.org/wiki/EAR_(file_format)

Has a collection of War and Jar, run in Application servers like JBoss and GlassFish 拥有War和Jar的集合,可在JBoss和GlassFish等应用程序服务器中运行

Additional War vs ear see .war vs .ear file 有关War的详细信息,请参见.war的.ear文件。

WARs are specifically intended to live in isolation from the other jars/ejbs in the package, they have their own classloader and the wars do not by default reside in the path in any other war, jar, or ejb. WAR专门用于与程序包中的其他jar / ejb隔离,它们具有自己的类加载器,并且war默认情况下不驻留在任何其他war,jar或ejb的路径中。

If there is a common functionality this should be moved into a jar that is shared between the artifacts. 如果存在通用功能,则应将其移入工件之间共享的jar中。

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

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