简体   繁体   中英

How can I disable Servlet classpath scanning for WebApplicationInitializer classes but still explictly use my own instance?

As per this question

How to disable Servlet 3.0 scanning and auto loading of components

I disabled classpath scanning for WebApplicationInitializer classes by setting metadata-complete="false" in my web.xml <web-app> element as well as adding a tag <absolute-ordering/> within my <web-app> tag.

Now no instances of WebApplicationInitializer run and it appears WebApplicationInitializer is the only way to programmatically add servlets/filters/listeners instead of in web.xml.

I want to disable all WebApplicationInitializer classes except my own which will have a bunch of entries. How can I configure this?

FYI I tried adding <absolute-ordering> like this

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         metadata-complete="false">
    <absolute-ordering>
        <name>com.company.project.MySuperSpecialWebAppInitializer</name>
    </absolute-ordering>

But it did not run my WebApplicationInitializer class.

是不是metadata-complete =“ true”,而不是“ false”?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM