Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
szpt
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
以墨为白
szpt
Commits
d6528ae4
Commit
d6528ae4
authored
Apr 02, 2025
by
以墨为白
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swagger替换成knife4j。注意springboot版本和knife4j版本的对应关系
parent
937de8ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
11 deletions
+25
-11
pom.xml
pom.xml
+14
-8
src/main/java/com/zksy/szpt/config/SwaggerConfig.java
src/main/java/com/zksy/szpt/config/SwaggerConfig.java
+10
-2
src/main/java/com/zksy/szpt/config/WebConfig.java
src/main/java/com/zksy/szpt/config/WebConfig.java
+1
-1
No files found.
pom.xml
View file @
d6528ae4
...
...
@@ -116,15 +116,21 @@
</dependency>
<!--swagger2-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>2.9.2</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>2.9.2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
2.9.2
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
2.9.2
</version>
<groupId>
com.github.xiaoymin
</groupId>
<artifactId>
knife4j-spring-boot-starter
</artifactId>
<version>
2.0.7
</version>
</dependency>
<dependency>
...
...
src/main/java/com/zksy/szpt/config/SwaggerConfig.java
View file @
d6528ae4
...
...
@@ -14,8 +14,9 @@ import springfox.documentation.service.Contact;
import
springfox.documentation.service.Parameter
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
WebMvc
;
import
org.springframework.beans.factory.annotation.Value
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -24,10 +25,15 @@ import java.util.List;
* Created by wcy on 2023/5/14.
*/
@Configuration
@EnableSwagger2
@EnableSwagger2
WebMvc
@Profile
(
"dev"
)
//dev环境下开启swagger功能
public
class
SwaggerConfig
{
private
static
final
org
.
slf4j
.
Logger
log
=
org
.
slf4j
.
LoggerFactory
.
getLogger
(
SwaggerConfig
.
class
);
@Value
(
"${server.port:8005}"
)
private
String
port
;
@Bean
public
Docket
createRestApi
()
{
...
...
@@ -42,6 +48,8 @@ public class SwaggerConfig {
pars
.
add
(
param3
);
pars
.
add
(
param4
);
pars
.
add
(
param5
);
log
.
info
(
"http://localhost:{}/doc.html"
,
port
);
ApiInfo
apiInfo
=
new
ApiInfoBuilder
()
.
title
(
"模块服务接口文档"
)
.
description
(
"服务接口文档,遵循RESTful API设计规范"
)
...
...
src/main/java/com/zksy/szpt/config/WebConfig.java
View file @
d6528ae4
...
...
@@ -43,7 +43,7 @@ public class WebConfig implements WebMvcConfigurer {
registry
.
addResourceHandler
(
"/favicon.ico"
,
"/demo_upload.html"
,
"/images/favicon-32x32.png"
,
"/images/favicon-16x16.png"
,
"/excel/newsList.xlsx"
)
.
addResourceLocations
(
"classpath:/static/"
);
// 解决 swagger-ui.html 404报错
registry
.
addResourceHandler
(
"
swagger-ui
.html"
).
addResourceLocations
(
registry
.
addResourceHandler
(
"
doc
.html"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"/webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment