Official address
get address: https://gitee.com/xiaoym/knife4j
Start configuration
Please make sure the swagger configuration is correct before configuration. If swagger is not configured, please take a detour. Thank you.
Note: Although the interface is beautiful, there are still some minor problems, such as the comment information written in \r\n and will not wrap, etc.
1. Add vamen dependency
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.6</version>
</dependency>
2. Configure static resource access path mapping in MvcConfig
public class MvcConfig implements WebMvcConfigurer {
/**
* 静态资源访问路径映射
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
3. Add startup annotation @EnableKnife4j
// knife4j interface document, /doc.html
In the third step, I deleted this comment and it’s no problem, you don’t need to configure it
View effect
The best part is that he can document offline everywhere, chattering
-
Personal open source project (universal background management system) –> https://gitee.com/wslxm/spring-boot-plus2 , you can check it out if you like
-
This is the end of this article. If you find it useful, please like or pay attention to it. We will continue to update more content from time to time... Thank you for watching!