M2E Eclipse Maven Workspace resolution and CDI

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 07:24:45

问题


I have a war project A that I am deploying to JBoss AS7 that uses CDI and all works fine. But I want to use some classes in another project B, which I added to my pom.xml and turned on workspace resolution for, because these classes will be shared by multiple war projects.

Now these classes work perfectly fine as long as they are in the war project A, but when I move them to B, the CDI on them stops working. The other project B has a webapp/WEB-INF/beans.xml, but when looking at the deployed war of A, project B is represented as a jar containing only class files, no beans.xml. CDI will not work, no matter what I try.

The only solution to get the beans.xml included in B is to set Bs packaging to war, at which point it isn't packaged, but deployed as a directory (named like a jar), which makes JBoss crash, and which includes all the libraries A and B use a second time.

I'm a bit lost - am I really restricted to using a single monster project if I want to use CDI in this situation ?


回答1:


Your problem is you are following the war project structure into a jar project, so your configuration file is not ending up into your final project's classpath. In order to solve that, move it to /src/main/resources directory and Maven will manage to reallocate it when your built is done. Take a look to the Maven standard layout explanation.



来源:https://stackoverflow.com/questions/15035751/m2e-eclipse-maven-workspace-resolution-and-cdi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!