springboot 学习笔记

1.  application.yaml  application.properties区别

2. java -jar ****.jar  --spring.profiles.active=pro

3.  热部署  springboot-devtools  complier         ctrl+shift +alt +/

4. @Value("${value.common:123"})           yaml:   value.common:${defaultStr:12345}

application.run(" ------value.common=666");

优先级:  args> yaml> code

5. @validated   1.5.3 后 才有

   @configrationproperties ( prefix ="common”)   

 yaml: 

      common:

            host:

            port:  

   list:    // #{'${listParm}‘.split(’,‘)}

     -  aaa

     -  bbb

  map:

     key1:value1

     key2: value2

mapParam: "{key1:'value1', key2:'value2'}"

6.   lombok

 @data   @tostring(exclude="password")

7.  RestController   Controller 区别

8. logback configration..   application.yaml文件中  

  logging:

         file:

         level:   

actuator  监控,动态调整日志级别 ,   1.5 之后

9. springboot  json converter  默认 jackson   gson   fastjson(不支持)

10. 父工程 使用dependencyManage 引入springboot springcloud, 实现双继承时,需要加<type>pom></type><scope>import</scope>

11.  spring-cloud-config-server   配置:

 spring.cloud.config.server.git.username

 spring.cloud.config.server.git.password

 spring.cloud.config.server.git.uri

 spring.cloud.config.server.git.searchPaths:/{application}

 spring.cloud.config.server.git.fore-pull:true

 spring.cloud.config.server.git.basedir: /var/config      // 默认为/tmp下, 此处需要修改    配置存放的目录

 

spring-cloud-config-client配置: bootstrap.yml

 spring.cloud.config.uri: http://127.0.0.1:8888

  spring.cloud.config.fail-fast: true

server.port:8881

 

@Data

@configproperties(prefix="")  //推荐使用

public class Cloudconfig{}

 

@EnableConfigurationProperties(CloudConfig.class)         放在controller上

@Resource

private CloudConfig cloudconfig;   

优先级: 

        1》2》3

1.项目目录里面的配置   /application-name    项目独立的配置

2. 仓库根目录里面的配置   /                           统一的配置

3. 代码本地的配置                                         开发环境经常需要修改的配置

 

 

如何 实现 动态更新:

1. acturator 引入

2. management.address

   management.security.enable:false

3. Cloudconf配置类 @RefreshScope

4. controller类 @RefreshScope

@hystrixcommand 默认10个并发

 commandproperties={@hystrixProperty(name="execution.isolation.strategy",value="Thread"}

服务限流策略:  线程池   信号量

 

commandproperties={@hystrixProperty(name="execution.isolation.strategy",value="Thread"}},
ThreadPoolProperty={@HystrixProperty(name="coreSize",value="13")}}

 

常用配置项:

---------------springcloud 2.0.0

server.port

server.tomcat.accept-count:1200

server.tomcat.max-connections:1000
                      max-threads:1000

                      min-spare-threads:100

spring.application.name

spring.datasource.hikari.mininum-idle:10

                                       maximum-pool-size:15
                             type: com.zaxxer.hikari.HikariDataSource

          redis.cluster.max-redirects:3

          jackson.serilization.write-dates-as-timestamps: true

         servlet.multipart.max-file-size: 1MB

                                    max-request-size:10MB

feign.hystrix.enabled: true

mybatis.configuration.map-underscore-to-camel-case: true

ribbon.ReadTimeout: 30000

          ConnectTimeout: 30000

 

---------------springboot 1.5.9

hystrix.threadpool.default.coreSize: 200

spring.zipkin.base-url:  ..........:9411

          sleuth.sampler.percentage: 1  生产环境改为0.1

          kafka.consumer.auto-offset-reset: earliest

                                    group-id

                                    key-deserializer : org.apache.kafka.common.serialization.StringDeserializer

                                    value-deserializer: org.apache.kafka.common.serialization.StringDeserializer

                    producer:

            key-serializer : org.apache.kafka.common.serialization.StringSerializer

                                    value-serializer: org.apache.kafka.common.serialization.StringSerializer

 eureka.client.registerWithEureka: true

                      fetchRegistry: true

                      serviceUrl.defaultZone

            instance.prefer-ip-address: true

feign.hystrix.enabled: true

hystrix.threadpool.default.coreSize: 200

                                  

 

转载于:https://www.cnblogs.com/xifenglou/p/8086224.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值