Front-end and back-end separation of SSM configuration swagger interface documents


Springboot was previously configured, which is much simpler than ssm. Now record the configuration of SSM

Adding dependencies to pom. XML

Springfox wrapped the swagger so that he could support spring MVC - >.

Add the configuration class SwaggerConfig. Java

@ComponentScan(basePackages = "com.maxcore.controller")
public class SwaggerConfig {

    public Docket customDocket() {
        return new Docket(DocumentationType.SWAGGER_2)

    private ApiInfo apiInfo() {
        Contact contact = new Contact ("Na", "", "[email protected]");
        Return new ApiInfo ("Simulated Brief Book Front Desk API Interface", // Headline title
                Swagger Test Demo, // Subtitle
                "0.0.1", //Version
                "Blog", // Link Displays Text
                "Https://"//website link


Add the following configuration in dispatcher-servlet.xml (springmvc configuration file)

    <bean class="com.maxcore.config.SwaggerConfig" />

    <mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/" />
    <mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/" />

To add comments to the controller layer

Finally, start the project, access to swagger interface documents must be right, otherwise always report 404, you think you have not configured the right, in fact, your path is wrong, the author here expressed a very painful understanding.

The author’s local access path is http://localhost/jianShuSSM_w…

Generally speaking.
Http://ip address: port (default 80, not shown)/project name/swagger-ui.html



Personal website