M2E Eclipse Maven工作区分辨率和CDI [英] M2E Eclipse Maven Workspace resolution and CDI

查看:159
本文介绍了M2E Eclipse Maven工作区分辨率和CDI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个战争项目A,该项目正在部署到使用CDI的JBoss AS7中,并且一切正常.但是我想在另一个项目B中使用某些类,我将其添加到pom.xml中并为其打开工作空间解析,因为这些类将由多个war项目共享.

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.

现在,只要这些类在战争项目A中,它们就可以很好地工作,但是当我将它们移至B时,它们上的CDI将停止工作.另一个项目B有一个webapp/WEB-INF/beans.xml,但是当查看A的部署战争时,项目B被表示为一个仅包含类文件而不包含bean.xml的jar.无论我如何尝试,CDI都无法工作.

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.

获取B中包含的beans.xml的唯一解决方案是将Bs打包设置为war,这时不打包它,而是将其部署为目录(命名为jar),这会使JBoss崩溃,并且包括所有库A和库B的第二次使用.

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.

我有点迷茫-如果我想在这种情况下使用CDI,我真的仅限于使用单个Monster项目吗?

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

推荐答案

您的问题是,您将war项目结构跟踪到jar项目中,因此您的配置文件没有最终到达最终项目的classpath中.为了解决这个问题,将其移动到/src/main/resources 目录,完成构建后, Maven 将设法重新分配它.看看 Maven标准布局说明.

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.

这篇关于M2E Eclipse Maven工作区分辨率和CDI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆