spring boot是典型的約定大於配置,那麼頗有必要對在開發過程當中這些配置作統一的添加記錄,以避免用到的時候處處搜索,網上的東西又參差不齊。mysql
server.port=8880
微服務註冊中心,yml文件redis
server: port: 8761 # 服務在啓動時,會把本身當作一個 Eureka 客戶端去註冊到 Eureka 服務器上,且從服務器上拉取信息 # 而該服務自己就是一個 Eureka 服務器 eureka: client: # 聲明是否將本身的信息註冊到 Eureka 服務器上 register-with-eureka: false # 是否到 Eureka 服務器中抓取註冊信息 fetch-registry: false service-url: defaultZone: http://localhost:8761/eureka instance: hostname: localhost # 心跳檢測檢測與續約時間 # 測試時將值設置設置小些,保證服務關閉後註冊中心能及時踢出服務 # 每間隔1s,向服務端發送一次心跳,證實本身依然」存活「 lease-renewal-interval-in-seconds: 1 # 告訴服務端,若是我2s以內沒有給你發心跳,就表明我「死」了,將我踢出掉。 lease-expiration-duration-in-seconds: 2 server: # 測試時關閉自我保護機制,保證不可用服務及時踢出 沒法出現RENEWALS ARE LESSER THAN THE THRESHOLD. THE SELF PRESERVATION MODE IS TURNED OFF.THIS MAY NOT PROTECT INSTANCE EXPIRY IN CASE OF NETWORK/OTHER PROBLEMS. enable-self-preservation: true spring: application: name:master #啓用shutdown endpoints: shutdown: enabled : true # 禁用密碼驗證 sensitive : false
數據庫,mysqlspring
spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://test:3306/sy?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE&zeroDateTimeBehavior=convertToNull spring.datasource.username=test spring.datasource.password=test
rabbitmqsql
spring.rabbitmq.host=test spring.rabbitmq.port=5672 spring.rabbitmq.username=test spring.rabbitmq.password=test spring.rabbitmq.publisher-confirms=true spring.rabbitmq.virtual-host=/
靜態文件數據庫
spring.resources.static-locations = classpath:/templates/,classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
security
security.user.name=admin security.user.password=123456 security.basic.path=/manage management.security.role=SUPERUSER
endpoints方式中止服務器
endpoints.shutdown.enabled=true endpoints.shutdown.sensitive=true
文件上傳限制app
spring.http.multipart.maxFileSize=10MB
spring.http.multipart.maxRequestSize=50MB
統一添加url地址,在微服務中特別有用elasticsearch
server.context-path=/admin
redis微服務
spring.redis.host = localhost spring.redis.port = 6379 spring.redis.timeout = 10000 spring.redis.database = 0 spring.redis.pool.max-active = 100 spring.redis.pool.max-wait = -1 spring.redis.pool.max-idle = 8 spring.redis.pool.min-idle = 0
elasticsearch測試
elasticsearch.ip=test elasticsearch.port=9300 elasticsearch.cluster.name=my-elasticsearch elasticsearch.pool=100 elasticsearch.index=visual elasticsearch.type=plate-pictrue
fastdfs
fastdfs.minPoolSize=10 fastdfs.maxPoolSize=30 fastdfs.waitTimes=200 connect_timeout = 2 network_timeout = 30 charset = UTF-8 http.tracker_http_port = 8180 tracker_server = localhost:22122
時間格式化,全局配置
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
若是代碼中須要用到日期那在代碼中
@JsonFormat(pattern = "yyyy-MM-dd") private Date brithday;
微服務
#微服務註冊中心 eureka.client.serviceUrl.defaultZone=http://test:8761/eureka/ #微服務應用名稱 spring.application.name=sy-admin #微服務名稱,經過此名稱來訪問 spring.service.name=sy-admin #微服務實例地址 eureka.instance.hostname=localhost