Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
b9f2d79d
提交
b9f2d79d
authored
3月 06, 2024
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 优化 swagger 打印接口文档地址根据 server.address 配置决定
上级
c3352821
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
19 行增加
和
7 行删除
+19
-7
application-monitor.yml
app/src/main/resources/application-monitor.yml
+7
-4
application.yml
app/src/main/resources/application.yml
+0
-1
SwaggerConfig.java
...rc/main/java/com/yiring/common/swagger/SwaggerConfig.java
+12
-2
没有找到文件。
app/src/main/resources/application-monitor.yml
浏览文件 @
b9f2d79d
...
...
@@ -4,6 +4,7 @@ server:
# Sentry
sentry
:
# https://sentry.yiring.com
# TODO: 替换成正式项目的 Sentry DSN
# basic-api
dsn
:
https://fec8292ec19b34fd541c75f907fcec9b@sentry.yiring.com/2
traces-sample-rate
:
1.0
...
...
@@ -14,14 +15,16 @@ spring:
boot
:
admin
:
client
:
url
:
http://127.0.0.1:18891
# url: http://127.0.0.1:18891
url
:
https://sbas.yiring.com
username
:
admin
password
:
spa.developer@Yiring.com
password
:
sba.developer@Yiring.com
instance
:
# TODO: 替换成正式项目的 Spring Boot Admin Server URL
management-base-url
:
http://39.100.252.176:42100/api
# Spring Boot Actuator
management
:
server
:
port
:
8182
endpoints
:
web
:
exposure
:
...
...
app/src/main/resources/application.yml
浏览文件 @
b9f2d79d
...
...
@@ -2,7 +2,6 @@ app:
version
:
${version}
server
:
address
:
127.0.0.1
port
:
8081
servlet
:
context-path
:
/api
...
...
basic-common/doc/src/main/java/com/yiring/common/swagger/SwaggerConfig.java
浏览文件 @
b9f2d79d
...
...
@@ -4,6 +4,7 @@ package com.yiring.common.swagger;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.lang.Console
;
import
cn.hutool.core.net.NetUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.yiring.common.core.I18n
;
import
io.swagger.v3.oas.models.ExternalDocumentation
;
import
io.swagger.v3.oas.models.OpenAPI
;
...
...
@@ -24,6 +25,7 @@ import org.springframework.boot.CommandLineRunner;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.core.env.Environment
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
...
...
@@ -57,6 +59,7 @@ public class SwaggerConfig implements CommandLineRunner {
String
appVersion
;
final
I18n
i18n
;
final
Environment
environment
;
@Bean
public
OpenAPI
api
()
{
...
...
@@ -182,9 +185,16 @@ public class SwaggerConfig implements CommandLineRunner {
@Override
public
void
run
(
String
...
args
)
{
LinkedHashSet
<
String
>
ips
=
new
LinkedHashSet
<>();
String
serverAddress
=
environment
.
getProperty
(
"server.address"
);
if
(
StrUtil
.
isBlank
(
serverAddress
))
{
ips
.
addAll
(
NetUtil
.
localIpv4s
());
}
else
{
ips
.
add
(
serverAddress
);
}
String
protocol
=
"http"
;
String
link
=
NetUtil
.
localIpv4s
()
String
link
=
ips
.
stream
()
.
map
(
host
->
"> "
+
protocol
+
"://"
+
host
+
":"
+
port
+
path
+
"/doc.html"
)
.
collect
(
Collectors
.
joining
(
"\n\t\t"
));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论