web.xml文件中的metadata-comcomplete屬性的作用:
該屬性指定當前的部署描述文件是否是完全的。如果設置為true,則容器在部署時只依賴部署描述文件,忽略所有的注解(同時也會跳過web-fragment.xml的掃描,亦即禁用可插性支持);如果設置為false或不配置該屬性,則表示啟用注解支持(和可插性支持)。
注解有效的web.xml(metadata-complete="false"或者直接刪除)
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" metadata-complete="false" version="3.1"> </web-app>
注解無效的web.xml(metadata-complete="true")
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" metadata-complete="true" version="3.1"> </web-app>