Spring 3.1 WebApplicationInitializer & Embedded Jetty 8 AnnotationConfiguration

后端 未结 13 1154
無奈伤痛
無奈伤痛 2020-12-13 14:16

I\'m trying to create a simple webapp without any XML configuration using Spring 3.1 and an embedded Jetty 8 server.

However, I\'m struggling to get Jetty to recogni

13条回答
  •  臣服心动
    2020-12-13 14:27

    To make it work on Jetty 9 set attribute AnnotationConfiguration.CLASS_INHERITANCE_MAP on WebAppContext

    webAppContext.setAttribute(AnnotationConfiguration.CLASS_INHERITANCE_MAP, createClassMap());
    

    And here is how to create this map:

    private ClassInheritanceMap createClassMap() {
        ClassInheritanceMap classMap = new ClassInheritanceMap();
        ConcurrentHashSet impl = new ConcurrentHashSet<>();
        impl.add(MyWebAppInitializer.class.getName());
        classMap.put(WebApplicationInitializer.class.getName(), impl);
        return classMap;
    }
    

    I placed that solution on gitHub

提交回复
热议问题