Spring 3.1 WebApplicationInitializer & Embedded Jetty 8 AnnotationConfiguration

后端 未结 13 1163
無奈伤痛
無奈伤痛 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条回答
  •  旧时难觅i
    2020-12-13 14:40

    Jetty 9 version of "magomarcelo" answer:

            context.setConfigurations(
                new org.eclipse.jetty.webapp.Configuration[] { new WebXmlConfiguration(), new AnnotationConfiguration() {
                    @Override
                    public void preConfigure(WebAppContext context) throws Exception {
                        final ClassInheritanceMap map = new ClassInheritanceMap();
                        final ConcurrentHashSet set = new ConcurrentHashSet<>();
                        set.add(MyWebAppInitializer.class.getName());
                        map.put(WebApplicationInitializer.class.getName(), set);
                        context.setAttribute(CLASS_INHERITANCE_MAP, map);
                        _classInheritanceHandler = new ClassInheritanceHandler(map);
                    }
                } });
    

提交回复
热议问题