我对jboss模块中的依赖关系有疑问。 我有一个弹簧应用程序,其结构如下:
myApp.war/
--/WEB-INF
--/classes/com/myapp/monitoring/IMonitoring.class
--/classes/com/myapp/monitoring/MonitoringFirst.class
--/lib
my-core.jar
IMonitoring.class定义监控类的合同 MonitoringFirst.class提供了mornitoring的实现,它还使用了my-core.jar中定义的一些类来进行日志记录,因此它依赖于my-core.jar在Spring中我定义了bean:
<bean id="myMonitoring" class="com.myapp.monitoring.MonitoringFirst">
然后我决定准备IMonitoring.class的另一个实现,并在sepatare jar中作为jboss模块中的模块提供它,所以在jboss-deployment-structure.xml中我喜欢:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.myapp.my-customization" />
</dependencies>
</deployment>
</jboss-deployment-structure>
我的模块用
中的IMonitoring.class的第二个实现来定义jar <module xmlns="urn:jboss:module:1.0" name="com.myapp.my-customization">
<resources>
<resource-root path="customization.jar"/>
</resources>
<dependencies>
<module name="my-core.jar"/>
</dependencies>
</module>
然后在我的春天,我可以使用
<bean id="myMonitoring" class="com.myapp.monitoring.MonitoringSecond">
但由于MonitoringSecond也使用my-core.jar中定义的某些类进行日志记录,因此我必须将my-core.jar移动到jboss模块 - 否则MonitoringSecond.class中所需的类不可用,而且我有java.lang。 ClassNotFoundException:com.myapp.LogManager来自[Module&#34; com.myapp.my-customization:main&#34;来自本地模块加载器......
Unfortunatelly class used for logging purpose (com.myapp.LogManager in my-core.jar) need information about name of the war in which it is called from, what can be achieved by asking for URL like
URL url = LogManager.class.getResource(LogManager.class.getSimpleName() + ".class");
but this gives different results:
when class is located in myApp.war/WEB-INF/lib it gives:
vfs:/C:/server/bin/content/myApp.war/WEB-INF/lib/my-core.jar/com/myapp/LogManager.class
and I can determine war name
when class is located in jboss module it gives:
jar:file:/C:/server/modules/system/layers/base/com/myapp/my-customization/main/my-core.jar!/com/myapp/LogManager.class
and here I don't have info about war name
最后,实际问题:
是否有可能MonitoringSecond类可以使用/ WEB-INF / lib中定义的LogManager.class,以便我不会强制将my-core.jar移动到jboss模块?
如果没有,还有其他一些想法来确定调用LogManager.class的战争名称?
希望我没有太多混淆它。 谢谢你的回答。问候。
答案 0 :(得分:0)
$ JBOSS_HOME / modules中的模块无法依赖部署WAR(动态模块)。因此无法在war lib文件夹中维护my-core.jar,my-core.jar必须位于$ JBOSS_HOME / modules
中