Skip to content

Spring No XML Example #17

@mlaccetti

Description

@mlaccetti

Not entirely sure if this belongs here or on the actual swagger-springmvc project; tried to follow the given steps to get Swagger working with SpringMVC in a no XML environment: servlet 3, @configuration everywhere. Ended up doing the following:

  1. Add a PropertyPlaceholderConfigurer to the existing Spring configuration class:
@Bean
public static PropertyPlaceholderConfigurer swaggerProperties() {
    final PropertyPlaceholderConfigurer swaggerProperties = new PropertyPlaceholderConfigurer();
    swaggerProperties.setLocation(new ClassPathResource("swagger.properties"));
    return swaggerProperties;
}
  1. Modify the WebApplicationInitializer to load the DocumentationConfig:
// Create the 'root' Spring application context
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(SpringBaseConfiguration.class, SpringWebConfiguration.class, DocumentationConfig.class);

I didn't have to create any other beans or instantiate any other objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions