springcloud 一个非常适用于中小企业的后台继承框架;在单一暴露的application.properties/yaml文件中直接配置即可完成,如果springcloud以模块化按业务分割后,并不建议使用springcloud config ;原因这个不成熟,有点不好用;建议使用携程的Apollo
以下为方便以后的开发工作做整理备份:其中properties 和 yaml 配置内容项是对应的
properties备份:
#定义服务名称
spring.application.name =springclouddemo
#定义普通参数
spring.http.encoding.force = true
spring.http.charset = UTF-8
spring.http.enabled = true
#定制本服务端口
server.port = 8002
server.tomcat.uri-encoding = UTF-8
# mysql数据库
spring.datasource.url=jdbc:mysql://101.210.215.204:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.driverClassName=com.mysql.jdbc.Driver
#集成alibaba的druid
spring.datasource.type = com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
spring.datasource.filters = stat
spring.datasource.maxActive = 20
spring.datasource.initialSize = 1
spring.datasource.maxWait = 60000
spring.datasource.minIdle = 1
spring.datasource.timeBetweenEvictionRunsMillis = 60000
spring.datasource.minEvictableIdleTimeMillis = 300000
spring.datasource.validationQuery = select 'x'
spring.datasource.testWhileIdle = true
spring.datasource.testOnBorrow = false
spring.datasource.testOnReturn = false
spring.datasource.poolPreparedStatements = true
spring.datasource.maxOpenPreparedStatements = 20
#redis
spring.redis.host = 101.215.804.913
spring.redis.port = 6379
spring.redis.password =
spring.redis.pool.max-idle = 300
spring.redis.pool.min-idle = 10
spring.redis.pool.max-active = 600
spring.redis.pool.max-wait = 1000
spring.redis.timeout = 60
#mybatis配置
mybatis.config-location = classpath:mybatis-config.xml
mybatis.mapperLocations = classpath:mapper/*.xml
#eoreka 注册服务
eureka.client.serviceUrl.defaultZone = http://localhost:1001/eureka/
#zuul路由地址
zuul.routes.api-a.path = /lowl/**
zuul.routes.api-a.serviceId = old-owl-client
zuul.routes.api-b.path = /springclouddemo/**
zuul.routes.api-b.serviceId = api
#断路器超时设定
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=6000
#普通配置项
email_url =http://110.281.45.21:8000/
#mongo配置项目
spring.data.mongodb.uri=mongodb://hootersopr:paic1234@10.59.97.10:27017/hooters
yaml的备份:
spring:
application:
name: springclouddemo
#定义数据源以及连接池等
datasource:
name: sdip
url: jdbc:mysql://101.201.215.24:3306/databasename
username: user
password: pass
# 使用druid数据源
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
filters: stat
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
#集成redis
redis:
host: 110.210.215.24
port: 7000
password: null
pool:
max-idle: 300
min-idle: 10
max-active: 600
max-wait: 1000
timeout: 0
#集成mongo数据库
data:
mongodb:
uri: mongodb://user:password@110.159.27.120:27017/dbname
#集成mybatis
mybatis:
config-location: classpath:mybatis-config.xml
mapperLocations: classpath:mapper/*.xml
#定义服务端口
server:
port: 8888
#定义项目
context-path: /api
#集成kafka
kafka:
binder:
brokers: 110.210.215.24:9091 #多个则在此以英文逗号“,”分开
group: test-group #定义所在组
#注册到eureka
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8001/eureka/
mybatis-config.xml 配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
<setting name="defaultEnumTypeHandler" value="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
</settings>
</configuration>