springboot 學習筆記

1.  application.yaml  application.properties區別java

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

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

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

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

優先級:  args> yaml> codejson

5. @validated   1.5.3 後 纔有bootstrap

   @configrationproperties ( prefix ="common」)   tomcat

 yaml: springboot

      common:mybatis

            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

相關文章
相關標籤/搜索