Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
项目统一框架
amos-boot-biz
Commits
ad20175c
Commit
ad20175c
authored
May 28, 2021
by
李成龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化swagger
parent
15461b6e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
76 additions
and
65 deletions
+76
-65
org.eclipse.jdt.core.prefs
amos-boot-biz-common/.settings/org.eclipse.jdt.core.prefs
+1
-0
oConvertUtils.java
...com/yeejoin/amos/boot/biz/common/utils/oConvertUtils.java
+0
-0
Swagger2Config.java
...java/com/yeejoin/amos/boot/biz/config/Swagger2Config.java
+44
-43
Swagger2.java
.../java/org/typroject/tyboot/core/restful/doc/Swagger2.java
+9
-0
org.eclipse.jdt.core.prefs
amos-boot-jcs-system/.settings/org.eclipse.jdt.core.prefs
+1
-0
AmosJcsApplication.java
...em/src/main/java/com/yeejoin/amos/AmosJcsApplication.java
+14
-11
application.properties
...boot-jcs-system/src/main/resources/application.properties
+1
-9
org.eclipse.jdt.core.prefs
...s-boot-cloud-gateway/.settings/org.eclipse.jdt.core.prefs
+1
-0
org.eclipse.jdt.core.prefs
...-boot-module-jcs-api/.settings/org.eclipse.jdt.core.prefs
+1
-0
org.eclipse.jdt.core.prefs
...-boot-module-tzs-api/.settings/org.eclipse.jdt.core.prefs
+1
-0
org.eclipse.jdt.core.prefs
...-boot-module-jcs-biz/.settings/org.eclipse.jdt.core.prefs
+1
-0
org.eclipse.jdt.core.prefs
...-boot-module-tzs-biz/.settings/org.eclipse.jdt.core.prefs
+1
-0
org.eclipse.jdt.core.prefs
amos-boot-tzs-system/.settings/org.eclipse.jdt.core.prefs
+1
-0
AmosTzsApplication.java
...em/src/main/java/com/yeejoin/amos/AmosTzsApplication.java
+0
-2
pom.xml
pom.xml
+0
-0
No files found.
amos-boot-biz-common/.settings/org.eclipse.jdt.core.prefs
View file @
ad20175c
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
...
...
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/oConvertUtils.java
0 → 100644
View file @
ad20175c
This diff is collapsed.
Click to expand it.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/config/Swagger2Config.java
View file @
ad20175c
...
...
@@ -30,29 +30,30 @@ import springfox.documentation.service.SecurityScheme;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spi.service.contexts.SecurityContext
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc
;
/**
* @Author lichenglong
*/
//@Configuration
//@EnableSwagger2
//@EnableKnife4j
//@Import(BeanValidatorPluginsConfiguration.class)
@Configuration
@EnableSwagger2
@EnableKnife4j
@Import
(
BeanValidatorPluginsConfiguration
.
class
)
public
class
Swagger2Config
implements
WebMvcConfigurer
{
@EnableSwagger2WebMvc
public
class
Swagger2Config
{
/**
*
* 显示swagger-ui.html文档展示页,还必须注入swagger资源:
*
//
*
* @param registry
*/
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
registry
.
addResourceHandler
(
"swagger-ui.html"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"doc.html"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"/webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
//
@Override
//
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
//
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
//
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
//
}
/**
* swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等
...
...
@@ -71,9 +72,9 @@ public class Swagger2Config implements WebMvcConfigurer {
.
apis
(
RequestHandlerSelectors
.
withClassAnnotation
(
RestController
.
class
))
.
apis
(
RequestHandlerSelectors
.
withMethodAnnotation
(
ApiOperation
.
class
))
.
paths
(
PathSelectors
.
any
())
.
build
()
.
securitySchemes
(
Collections
.
singletonList
(
securityScheme
()))
.
securityContexts
(
securityContexts
());
.
build
()
;
//
.securitySchemes(Collections.singletonList(securityScheme()))
//
.securityContexts(securityContexts());
//.globalOperationParameters(setHeaderToken());
}
...
...
@@ -83,21 +84,21 @@ public class Swagger2Config implements WebMvcConfigurer {
* http://localhost:8888/webjars/springfox-swagger-ui/o2c.html
* @return
*/
@Bean
SecurityScheme
securityScheme
()
{
return
new
ApiKey
(
CommonConstant
.
X_ACCESS_TOKEN
,
CommonConstant
.
X_ACCESS_TOKEN
,
"header"
);
}
//
@Bean
//
SecurityScheme securityScheme() {
//
return new ApiKey(CommonConstant.X_ACCESS_TOKEN, CommonConstant.X_ACCESS_TOKEN, "header");
//
}
/**
* JWT token
* @return
*/
private
List
<
Parameter
>
setHeaderToken
()
{
ParameterBuilder
tokenPar
=
new
ParameterBuilder
();
List
<
Parameter
>
pars
=
new
ArrayList
<>();
tokenPar
.
name
(
CommonConstant
.
X_ACCESS_TOKEN
).
description
(
"token"
).
modelRef
(
new
ModelRef
(
"string"
)).
parameterType
(
"header"
).
required
(
false
).
build
();
pars
.
add
(
tokenPar
.
build
());
return
pars
;
}
//
private List<Parameter> setHeaderToken() {
//
ParameterBuilder tokenPar = new ParameterBuilder();
//
List<Parameter> pars = new ArrayList<>();
//
tokenPar.name(CommonConstant.X_ACCESS_TOKEN).description("token").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
//
pars.add(tokenPar.build());
//
return pars;
//
}
/**
* api文档的详细信息函数,注意这里的注解引用的是哪个
...
...
@@ -123,22 +124,22 @@ public class Swagger2Config implements WebMvcConfigurer {
/**
* 新增 securityContexts 保持登录状态
*/
private
List
<
SecurityContext
>
securityContexts
()
{
return
new
ArrayList
(
Collections
.
singleton
(
SecurityContext
.
builder
()
.
securityReferences
(
defaultAuth
())
.
forPaths
(
PathSelectors
.
regex
(
"^(?!auth).*$"
))
.
build
())
);
}
private
List
<
SecurityReference
>
defaultAuth
()
{
AuthorizationScope
authorizationScope
=
new
AuthorizationScope
(
"global"
,
"accessEverything"
);
AuthorizationScope
[]
authorizationScopes
=
new
AuthorizationScope
[
1
];
authorizationScopes
[
0
]
=
authorizationScope
;
return
new
ArrayList
(
Collections
.
singleton
(
new
SecurityReference
(
CommonConstant
.
X_ACCESS_TOKEN
,
authorizationScopes
)));
}
//
private List<SecurityContext> securityContexts() {
//
return new ArrayList(
//
Collections.singleton(SecurityContext.builder()
//
.securityReferences(defaultAuth())
//
.forPaths(PathSelectors.regex("^(?!auth).*$"))
//
.build())
//
);
//
}
//
//
private List<SecurityReference> defaultAuth() {
//
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
//
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
//
authorizationScopes[0] = authorizationScope;
//
return new ArrayList(
//
Collections.singleton(new SecurityReference(CommonConstant.X_ACCESS_TOKEN, authorizationScopes)));
//
}
}
amos-boot-biz-common/src/main/java/org/typroject/tyboot/core/restful/doc/Swagger2.java
0 → 100644
View file @
ad20175c
package
org
.
typroject
.
tyboot
.
core
.
restful
.
doc
;
/**
* 此类是为了覆盖原有类,为空,不用写具体实现
* @author lichenglong
*
*/
public
class
Swagger2
{
}
amos-boot-jcs-system/.settings/org.eclipse.jdt.core.prefs
View file @
ad20175c
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
...
...
amos-boot-jcs-system/src/main/java/com/yeejoin/amos/AmosJcsApplication.java
View file @
ad20175c
package
com
.
yeejoin
.
amos
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -15,7 +18,8 @@ import org.springframework.context.annotation.ComponentScan;
import
org.springframework.core.env.Environment
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
import
com.yeejoin.amos.boot.biz.common.utils.oConvertUtils
;
/**
* <pre>
...
...
@@ -26,7 +30,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@EnableTransactionManagement
@EnableConfigurationProperties
@EnableSwagger2
@ServletComponentScan
@EnableDiscoveryClient
@EnableFeignClients
...
...
@@ -42,17 +45,17 @@ public class AmosJcsApplication
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AmosJcsApplication
.
class
);
public
static
void
main
(
String
[]
args
)
public
static
void
main
(
String
[]
args
)
throws
UnknownHostException
{
ConfigurableApplicationContext
context
=
SpringApplication
.
run
(
AmosJcsApplication
.
class
,
args
);
Environment
environment
=
context
.
getEnvironment
();
Environment
env
=
context
.
getEnvironment
();
String
ip
=
InetAddress
.
getLocalHost
().
getHostAddress
();
String
port
=
env
.
getProperty
(
"server.port"
);
String
path
=
oConvertUtils
.
getString
(
env
.
getProperty
(
"server.servlet.context-path"
));
logger
.
info
(
"The requested service of "
+
environment
.
getProperty
(
"spring.application.name"
)
+
" has already been started in "
+
environment
.
getProperty
(
"spring.profiles.active"
)
+
""
+
" environment,and service's url is 'http://localhost:"
+
environment
.
getProperty
(
"server.port"
)
+
environment
.
getProperty
(
"server.servlet.context-path"
)
+
"/swagger-ui.html'"
);
logger
.
info
(
"\n----------------------------------------------------------\n\t"
+
"Application Jeecg-Boot is running! Access URLs:\n\t"
+
"Swagger文档: \thttp://"
+
ip
+
":"
+
port
+
path
+
"/doc.html\n"
+
"----------------------------------------------------------"
);
}
}
amos-boot-jcs-system/src/main/resources/application.properties
View file @
ad20175c
spring.application.name
=
AIRPORT
server.servlet.context-path
=
/airPort
server.port
=
11000
spring.profiles.active
=
dev
#swagger开启
#swagger.enable=true
# 是否停用Knife4j文档
knife4j.production
=
false
knife4j.basic.enable
=
false
#knife4j.basic.username=jeecg
#
knife4j.basic.password
=
jeecg1314
\ No newline at end of file
amos-boot-module/amos-boot-cloud-gateway/.settings/org.eclipse.jdt.core.prefs
View file @
ad20175c
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-jcs-api/.settings/org.eclipse.jdt.core.prefs
View file @
ad20175c
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/.settings/org.eclipse.jdt.core.prefs
View file @
ad20175c
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/.settings/org.eclipse.jdt.core.prefs
View file @
ad20175c
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/.settings/org.eclipse.jdt.core.prefs
View file @
ad20175c
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
...
...
amos-boot-tzs-system/.settings/org.eclipse.jdt.core.prefs
View file @
ad20175c
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
...
...
amos-boot-tzs-system/src/main/java/com/yeejoin/amos/AmosTzsApplication.java
View file @
ad20175c
...
...
@@ -16,7 +16,6 @@ import org.springframework.context.annotation.ComponentScan;
import
org.springframework.core.env.Environment
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* <pre>
...
...
@@ -28,7 +27,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@EnableTransactionManagement
@EnableConfigurationProperties
@EnableSwagger2
@ServletComponentScan
@EnableDiscoveryClient
@EnableFeignClients
...
...
pom.xml
View file @
ad20175c
This diff is collapsed.
Click to expand it.
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