Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref config #217

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ docker-compose启动MySQL镜像时会自动执行初始化脚本,如已执行
127.0.0.1 www.goodskill.com
----

* 在Nacos配置中心中添加DataId为``goodskill-common-connection.yml``的服务公共配置,Group为``DEFAULT_GROUP``,具体内容可参考项目根目录中的``goodskill-common-connection.yml``文件

* main方法运行``OrderApplication``类(订单服务)

* main方法运行``SeckillApplication``类(秒杀管理服务提供者)
Expand Down
41 changes: 6 additions & 35 deletions goodskill-auth/auth-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,26 @@ server:
spring:
application:
name: goodskill-auth
datasource:
username: root
password: Password123
url: jdbc:mysql://mysql:3306/seckill?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&useSSL=false
cloud:
nacos:
username: nacos
password: nacos
server-addr: nacos:8848
config:
import: optional:nacos:goodskill-auth-service.yml
import: optional:nacos:goodskill-common-connection.yml
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql:3306/seckill?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&useSSL=false
username: root
password: Password123
flyway:
##是否开启自动升级表结构功能
enabled: true
baseline-on-migrate: true
clean-disabled: true
locations:
- classpath:db/migration/mysql
data:
redis:
password: 123456

management:
endpoint:
health:
show-details: always
endpoints:
web:
exposure:
include: '*'

############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: access_token
# token 有效期(单位:秒) 默认30天,-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
is-share: true
# token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
token-style: simple-uuid
# 是否输出操作日志
is-log: true
# 关闭banner打印
is-print: true
logging:
level:
com.goodskill: debug
Expand Down
103 changes: 103 additions & 0 deletions goodskill-common-connection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
spring:
mvc:
# json格式请求前台到后台的格式转换
format:
date: yyyy-MM-dd HH:mm:ss
date-time: yyyy-MM-dd HH:mm:ss
time: HH:mm:ss
rabbitmq:
host: rabbitmq
port: 5672
username: guest
password: guest
kafka:
bootstrap-servers: kafka:9092
elasticsearch:
uris: http://elasticsearch:9200
data:
redis:
port: 6379
host: redis
password: 123456
mongodb:
database: test
output:
ansi:
enabled: ALWAYS
graphql:
graphiql:
enabled: true
cloud:
loadbalancer:
retry:
enabled: false
openfeign:
client:
config:
default:
connect-timeout: 2000 # 连接超时时间,单位为毫秒
read-timeout: 4000 # 读取超时时间,单位为毫秒
sentinel:
transport:
port: 8719
## 默认端口8080,已改为自定义18088端口,通过http://127.0.0.1:18088/#/dashboard访问
dashboard: localhost:18088
##使用nacos配置中心存储限流规则
datasource:
ds0:
nacos:
data-id: ${spring.application.name}-flow-rules
data-type: json
group-id: DEFAULT_GROUP
rule-type: flow
server-addr: nacos:8848
username: nacos
password: nacos

mybatis-plus:
global-config:
db-config:
logic-delete-field: deleteFlag # 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2)
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)

management:
endpoint:
health:
show-details: always
endpoints:
web:
exposure:
include: '*'

dubbo:
registry:
address: zookeeper://zookeeper:2181

zookeeper_ip: zookeeper:2181

## oss配置
minio:
endpoint: http://localhost:19000
accessKey: YghdgTEEJnvvrUm5nX70
secretKey: hCv6xU4TEembK6Fr2pHvJWxlijKUXySDIS4sSTMK
bucketName: goodskill

############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: access_token
# token 有效期(单位:秒) 默认30天,-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
is-share: true
# token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
token-style: simple-uuid
# 是否输出操作日志
is-log: true
# 关闭banner打印
is-print: true
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.Date;
import java.util.Optional;
import java.util.UUID;

Expand Down Expand Up @@ -76,6 +77,8 @@ public Result<String> uploadFile(@RequestParam("file") MultipartFile file) {
fileNameMapping.setOriginalFileName(file.getOriginalFilename());
fileNameMapping.setUniqueFileName(uniqueFileName);
fileNameMapping.setFileMd5(fileMd5);
fileNameMapping.setCreateTime(new Date());
fileNameMapping.setUpdateTime(new Date());
fileNameMappingRepository.save(fileNameMapping);

// 返回上传文件的 URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.util.Date;

@Document(collection = "oss_file_name_mapping")
@Data
public class FileNameMapping {
@Id
@MongoId
private String id;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ server:
port: 18049

spring:
profiles:
active: dev
#系统名称
application:
name: goodskill-common
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql:3306/gs_sys?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&useSSL=false
username: root
password: Password123
cloud:
nacos:
username: nacos
password: nacos
server-addr: nacos:8848
config:
import: optional:nacos:goodskill-common-service.yml
import: optional:nacos:goodskill-common-connection.yml
main:
allow-circular-references: true
flyway:
Expand All @@ -41,12 +38,6 @@ dubbo:
# cloud:
# subscribed-services: ""

## oss配置
minio:
endpoint: http://localhost:19000
accessKey: YghdgTEEJnvvrUm5nX70
secretKey: hCv6xU4TEembK6Fr2pHvJWxlijKUXySDIS4sSTMK
bucketName: goodskill

seata:
enabled: false
Expand Down
8 changes: 4 additions & 4 deletions goodskill-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-gateway-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-bootstrap</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>com.goodskill</groupId>
<artifactId>goodskill-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public class DynamicRouteConfigWatcher implements CommandLineRunner {
private DynamicRouteRefresh dynamicRouteService;

private ConfigService configService;
@Value("${spring.cloud.nacos.discovery.server-addr}")
@Value("${spring.cloud.nacos.server-addr}")
private String NACOS_SERVER_ADDR;

@Value("${spring.cloud.nacos.discovery.namespace:}")
@Value("${spring.cloud.nacos.namespace:}")
private String NACOS_NAMESPACE;

@Value("${spring.cloud.nacos.discovery.group:DEFAULT_GROUP}")
@Value("${spring.cloud.nacos.group:DEFAULT_GROUP}")
private String NACOS_ROUTE_GROUP;

@Value("${spring.cloud.nacos.username}")
Expand Down
71 changes: 14 additions & 57 deletions goodskill-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
server:
port: 80
spring:
profiles:
active: dev
application:
name: goodskill-gateway
config:
import: optional:nacos:goodskill-common-connection.yml
main:
allow-bean-definition-overriding: true
cloud:
nacos:
username: nacos
password: nacos
server-addr: nacos:8848
sentinel:
filter:
## 网关服务此项需配置为false(若在网关流控控制台上看到了 URL 资源,就是此配置项没有置为 false)
enabled: false
transport:
port: 8719
## 默认端口8080,已改为自定义18088端口,通过http://127.0.0.1:18088/#/dashboard访问
dashboard: localhost:18088
##使用nacos配置中心存储限流规则
datasource:
ds0:
nacos:
data-id: ${spring.application.name}-flow-rules
# data-type: json
group-id: DEFAULT_GROUP
rule-type: gw-flow
server-addr: nacos:8848
username: nacos
password: nacos
gateway:
##开启指标监控
metrics:
Expand Down Expand Up @@ -63,22 +65,7 @@ spring:
- Path=/api/test
filters:
- RedirectTo=302, https://www.baidu.com, true
data:
redis:
password: 123456
host: redis
main:
allow-bean-definition-overriding: true

# 监控
management:
endpoint:
health:
show-details: always
endpoints:
web:
exposure:
include: '*'

nacos:
router:
Expand All @@ -88,9 +75,11 @@ nacos:
#接口白名单
security:
ignore:
##普通接口白名单
whiteUrl:
- "/api/auth/login"
- "/api/web/**"
##登录用户接口白名单
loginUserWhiteUrls:
- "/api/xxx"

Expand Down Expand Up @@ -131,37 +120,5 @@ knife4j:
# 指定版本号(Swagger2|OpenAPI3)
version : openapi3

############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: access_token
# token 有效期(单位:秒) 默认30天,-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
is-share: true
# token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
token-style: simple-uuid
# 是否输出操作日志
is-log: true
# 关闭banner打印
is-print: true

---
spring:
config:
activate:
on-profile: docker,dev
cloud:
nacos:
server-addr: nacos:8848
sentinel:
datasource:
ds0:
nacos:
server-addr: nacos:8848


Loading
Loading