简体   繁体   English

在不同包装下的两个不同罐子中的相同类。 它会在应用程序执行中引起任何问题吗?

[英]Same Classes in two different jars under different packages. Will it cause any issue in application execution?

I have an issue while running my application in weblogic server. 我在weblogic服务器中运行我的应用程序时遇到问题。 I have same classes in two different jars under differnt package. 我在不同包装下的两个不同的罐子里有相同的类。 Will it raise any issue at runtime? 它会在运行时引发任何问题吗?

Note : I am not facing any build issue. 注意:我没有遇到任何构建问题。

Sorry. 抱歉。 if I confused you all. 如果我把你们搞糊涂了

Advance Thanks 提前谢谢

If the fully classified class name (aka package + class name) is different, then there can be no problem at all. 如果完全分类的类名(aka包+类名)不同,那么根本就没有问题。 Java distinguishes classes by complete name that includes package (aka FQCN). Java通过包括包(也称为FQCN)的完整名称来区分类。 If two jars contain identical FQCN, then it depends on classloader order settings. 如果两个罐子包含相同的FQCN,那么它取决于类加载器的顺序设置。 When you deploy new ear (war) in app server, you can specify the order. 在app server中部署新耳(war)时,可以指定顺序。 More information for weblogic: http://docs.oracle.com/cd/E11035_01/wls100/programming/classloading.html 有关weblogic的更多信息: http//docs.oracle.com/cd/E11035_01/wls100/programming/classloading.html

There can't be a direct problem related to class - loading when using different full - qualified - classnames. 在使用不同的完全限定类名时,不能存在与类相关的直接问题。 There can be issues, though, with CDI. 但是,CDI可能存在问题。 Remember that Inject can be applied to many Resources, and the injection target can have the type of an interface rather then having the type of the implementing class. 请记住,Inject可以应用于许多资源,并且注入目标可以具有接口的类型,而不是具有实现类的类型。 When determinating on which object is to be instanciated, the application server /CDI container could run into problems when suddenly there may be more implementations of that interface available after a deployment then before, eg both annotated with the same or default qualifier, though a exception is expected here rather then a random injecting of one class or the other. 在确定要实例化哪个对象时,应用程序服务器/ CDI容器可能会遇到问题,突然之后可能会有更多的接口可用于部署之后,例如,使用相同或默认限定符进行注释,但是异常在这里,而不是随机注入一个类或另一个类。

As long as they are within different namespaces there will be no problems raised from having the same classes in different annything since they will have the name : package.class. 只要它们位于不同的名称空间内,就不会因为在不同的东西中使用相同的类而产生问题,因为它们将具有名称:package.class。 If i where you i would look for a different cause for runtime errors. 如果我在哪里,我会寻找运行时错误的不同原因。

And might i ask what makes you think this is the problem? 我可能会问你认为这是什么问题? do you have anny log or error refering to these specific classes? 你有没有引用这些特定类的日志或错误?

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

相关问题 是否可以使用来自两个不同 jars / 包的同名类编写通用代码 - Is it possible to write a generic code using classes with same name from two different jars / packages 在不同的 JARs 中加载两个类 - Loading two classes in different JARs 在Android应用程序中不同包中的两个不同类之间发送 - Sending between two different classes in different packages in Android Application Spring中不同包下的两个具有相同名称的控制器 - Two controllers with same name under different packages in Spring 如何在不同的包中导入两个具有相同名称的类? - How to import two classes with the same name in different packages? JPA如何识别具有相同名称但在不同包中的两个类? - How can the JPA recognize two classes with the same name but in different packages? 在不同的包中有两个同名的类的坏习惯? - Bad practice to have two classes of the same name in different packages? Java命名空间 - 两个在不同包中具有相同名称的类 - Java Namespace - Two classes with the same name in different packages 全局注册XmlAdapter以用于不同包中的任何类 - Registering XmlAdapter globally for any classes in different packages 将数据复制到不同包中的相同类 - Copy data to same classes in different packages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM