nacos配置
2020-08-19 本文已影响0人
angelali_90b4
1.第一步 配置pom,bootstrap.yml
spring:
spring:
main.allow-bean-definition-overriding: true
application:
name: boai-goods
cloud:
nacos:
discovery:
server-addr: ip:8848
cluster-name: boai-goods
config:
cluster-name: boai-goods
server-addr: ip:8848
<!-- nacos: 服务发现 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- 阿里巴巴: 结束 -->
2.第二步 创建 调用方法
package com.wmeimob.boai.feign.client.order;
import com.wmeimob.boai.common.dto.common.ResultBean;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(value ="boai-order")
public interface OrderClient {
@RequestMapping(value = "/api/order/kd100/common",method = RequestMethod.GET)
ResultBean<Object> getOrderOneLogistics();
}
以上配置完成完成后去下载本地nacos安装在window上面
- 解压后进入nacos/bin目录
/**
* 默认地址 http://127.0.0.1:8848/nacos
* 用户名 nacos
* 密码 nacos
*/
cmd 运行 startup.cmd
- nacos导入配置
//boai-admin
spring:
application:
name: boai-admin
cloud:
nacos:
discovery:
server-addr: ip:8848
cluster-name: boai-admin
config:
cluster-name: boai-admin
server-addr: ip:8848
//boai-custom
spring:
application:
name: boai-custom
cloud:
nacos:
discovery:
server-addr: ip:8848
cluster-name: boai-custom
config:
cluster-name: boai-custom
server-addr: ip:8848
//boai-gateway
server:
port: 8085
spring:
main.allow-bean-definition-overriding: true
application:
name: boai-gateway
cloud:
nacos:
discovery:
server-addr: ip:8848
cluster-name: boai-gateway
config:
cluster-name: boai-gateway
server-addr: ip:8848
gateway:
routes:
- id: boai-goods
uri: lb://boai-goods
order: 0
predicates:
- Path=/api/goods/**
- id: boai-custom
uri: lb://boai-custom
order: 0
predicates:
- Path=/api/custom/**
- id: boai-order
uri: lb://boai-order
order: 0
predicates:
- Path=/api/order/**
logstash:
tcp:
ip: 47.100.180.47
port: 5044
mybatis:
configuration:
map-underscore-to-camel-case: true
//boai-goods
spring:
cloud:
nacos:
discovery:
server-addr: ip:8848
cluster-name: boai-goods
config:
cluster-name: boai-goods
server-addr: ip:8848
//boai-order
spring:
cloud:
nacos:
discovery:
server-addr: ip:8848
cluster-name: boai-order
config:
cluster-name: boai-order
server-addr: ip:8848
//common.yaml
spring:
jackson:
default-property-inclusion: NON_NULL
serialization.write-dates-as-timestamps: true
date-format: yyyy/MM/dd HH:mm:ss
time-zone: GMT+8
servlet:
multipart:
max-request-size: 1024MB
max-file-size: 1024MB
datasource:
url: jdbc:mysql://rm-8vb58jwj95ts7l6i5.mysql.zhangbei.rds.aliyuncs.com:3306/boaib2c?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=true&serverTimezone=Asia/Shanghai
username: xx
password: xxx
driver-class-name: com.mysql.cj.jdbc.Driver
druid:
initial-size: 10
max-active: 20
test-on-borrow: true
validation-query: SELECT 1 FROM DUAL
validation-query-timeout: 300
stat-view-servlet:
login-username: wmeimob
login-password: 123456
filter:
stat:
enabled: true
log-slow-sql: true
wall:
enabled: true
config:
multi-statement-allow: true
redis:
database: 80
host: r-8vbetl3z547sbvf457pd.redis.zhangbei.rds.aliyuncs.com
password: xxxxxxxxxxx
port: 6379
timeout: 10000ms
lettuce:
pool:
max-active: 8
max-wait: 10000ms
max-idle: 8
min-idle: 0
shutdown-timeout: 100ms
session:
store-type: redis
cache:
type: redis
logging:
level:
org.springframework:
web: INFO
data: INFO
security: INFO
com.alibaba.nacos.naming: warn
com.alibaba.nacos.client.naming: warn
com.wmeimob: DEBUG
com.aliyun: DEBUG
feign:
hystrix:
enabled: true
httpclient:
enabled: false
okhttp:
enabled: true
hystrix:
threadpool:
default:
coreSize: 200
maxQueueSize: 200
queueSizeRejectionThreshold: 68
execution:
timeout:
enabled: true
isolation:
strategy: THREAD
semaphore:
maxConcurrentRequests: 1500
thread:
timeoutInMilliseconds: 30000
command.default:
execution.isolation.thread.timeoutInMilliseconds: 6000
circuitBreaker.sleepWindowInMilliseconds: 6000
circuitBreaker.forceClosed: true
execution.timeout.enabled: false
ribbon:
ReadTimeout: 6000
SocketTimeout: 6000
ConnectTimeout: 6000
okhttp:
enabled: true
http:
client:
enabled: false
mybatis:
mapper-locations:
- classpath:com/wmeimob/boai/common/mapper/**/impl/*.xml
type-aliases-package: com.wmeimob.boai.common.entity.*
configuration:
map-underscore-to-camel-case: true