Skip to content

Commit

Permalink
feat: spring cloud loadbalancer集成caffenine, 增加本地环境变量的配置,支持同机多环境的开发
Browse files Browse the repository at this point in the history
  • Loading branch information
david committed Jan 23, 2022
1 parent ad869d6 commit ff049e6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ temp/
# idea
.idea/
*.iml
*.iws
*.ipr

*velocity.log*

Expand All @@ -30,11 +32,6 @@ temp/
.factorypath
.springBeans

### IntelliJ IDEA ###
.idea
*.iws
*.ipr

### NetBeans ###
nbproject/private/
build/
Expand All @@ -44,3 +41,6 @@ nbdist/

*.log
tmp/

# 环境变量
local.env
32 changes: 19 additions & 13 deletions mate-core/mate-starter-cloud/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ spring:
cloud:
nacos:
config:
namespace: @config.namespace@
server-addr: @config.server-addr@
group: @config.group@
namespace: ${NACOS.NAMESPACE:@config.namespace@}
server-addr: ${NACOS.URL:@config.server-addr@}
group: ${NACOS.GROUP:@config.group@}
file-extension: yaml
prefix: mate
# shared-configs:
# - @artifactId@-@spring.active@.${spring.cloud.nacos.config.file-extension}
# refresh-enabled: true
# shared-configs[0]:
# data-id: @artifactId@.yaml
# group: DEFAULT_GROUP
# refresh: true
# shared-configs:
# - @artifactId@-@spring.active@.${spring.cloud.nacos.config.file-extension}
# refresh-enabled: true
# shared-configs[0]:
# data-id: @artifactId@.yaml
# group: DEFAULT_GROUP
# refresh: true
discovery:
namespace: @config.namespace@
server-addr: @config.server-addr@
namespace: ${NACOS.NAMESPACE:@config.namespace@}
server-addr: ${NACOS.URL:@config.server-addr@}
group: ${NACOS.GROUP:@config.group@}
watch:
enabled: false
sentinel:
Expand All @@ -33,7 +34,12 @@ spring:
eager: true
transport:
#port: @sentinel.port@
dashboard: @sentinel.dashboard@
dashboard: ${SENTINEL.URL:@sentinel.dashboard@}
loadbalancer:
cache:
enabled: true
caffeine:
spec: initialCapacity=500,expireAfterWrite=5s
feign:
sentinel:
enabled: true
6 changes: 6 additions & 0 deletions mate-core/mate-starter-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<lombok.version>1.18.20</lombok.version>
<hutool.version>5.7.19</hutool.version>
<spring.security.version>2.5.5</spring.security.version>
<caffeine.version>3.0.5</caffeine.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -600,6 +601,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>${caffeine.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
4 changes: 4 additions & 0 deletions mate-core/mate-starter-feign/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
Expand Down

0 comments on commit ff049e6

Please sign in to comment.