CDI - what is the correct bean.xml format?

隐身守侯 提交于 2019-12-05 01:50:22

Correct empty beans.xml can be totally empty file, really ;-)

But when you want to add some content, please notice that most of the XML deployment descriptor namespaces have been updated in Java EE 7. This post describes the details. Also bean-discovery-mode has been added.

BTW: Sample beans.xml which I'm using right now looks like:

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       version="1.2" bean-discovery-mode="annotated">

    <!-- some content -->
</beans>

You may notice the usage of version="1.2" attribute - you can freely set it to 1.1. It just serves as a reminder to the reader that project is using CDI 1.2 (which in fact is just a Maintenance release of the CDI 1.1 Specification).

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