1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢(xún)
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問(wèn)題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
      從SpringBoot1.5升級(jí)到2.0-創(chuàng)新互聯(lián)

      POM

      • 1.5
      
          org.springframework.boot
          spring-boot-starter-parent
          1.5.10.RELEASE
          
      
      • 2.0
      
          org.springframework.boot
          spring-boot-starter-parent
          2.0.7.RELEASE
          
      

      Spring Data

      Spring Data的一些方法進(jìn)行了重命名:

      創(chuàng)新互聯(lián)公司主營(yíng)點(diǎn)軍網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶APP開(kāi)發(fā)公司,點(diǎn)軍h5微信小程序開(kāi)發(fā)搭建,點(diǎn)軍網(wǎng)站營(yíng)銷(xiāo)推廣歡迎點(diǎn)軍等地區(qū)企業(yè)咨詢(xún)
      • findOne(id) -> findById(id) (返回的是Optional)
      • delete(id) -> deleteById(id)
      • exists(id) -> existsById(id)
      • findAll(ids) -> findAllById(ids)

      配置

      在升級(jí)時(shí),可以在pom中增加spring-boot-properties-migrator,這樣在啟動(dòng)時(shí)會(huì)提示需要更改的配置:

      
          org.springframework.boot
          spring-boot-properties-migrator
          runtime
      

      其中改動(dòng)較大的是security(The security auto-configuration is no longer customizable,A global security auto-configuration is now provided)、management、banner、server等。

      • security

      security開(kāi)頭的配置及management.security均已過(guò)期,如以下的配置不再支持,需要調(diào)整到代碼中:

      security:
        ignored: /api-docs,/swagger-resources/**,/swagger-ui.html**,/webjars/**
      • management
      management:
        security:
          enabled: false
        port: 8090

      修改為:

      management:
        server:
          port: 8090
      • datasource
      datasource:
          initialize: false

      修改為:

      datasource:
          initialization-mode: never

      如使用PostgreSQL,可能會(huì)報(bào)錯(cuò):Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented hibernate,需修改配置:

      jpa:
          database-platform: org.hibernate.dialect.PostgreSQLDialect
          properties:
             hibernate:
               default_schema: test
               jdbc:
                 lob:
                   non_contextual_creation: true
      • banner調(diào)整為spring.banner
      • server調(diào)整為server.servlet

      更多需要調(diào)整的參數(shù)請(qǐng)看文末參考文檔。

      Security

      WebSecurityConfigurerAdapter

      • security.ignored
      @Override
      public void configure(WebSecurity web) throws Exception {
         web.ignoring().antMatchers("/api-docs", "/swagger-resources/**", "/swagger-ui.html**", "/webjars/**");
      }
      • AuthenticationManager

      如在代碼中注入了AuthenticationManager,

      @Autowired
      private AuthenticationManager authenticationManager;

      在啟動(dòng)時(shí)會(huì)報(bào)錯(cuò):Field authenticationManager required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found.請(qǐng)?jiān)赪ebSecurityConfigurerAdapter中增加以下代碼:

      @Bean
      @Override
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return super.authenticationManagerBean();
      }

      Actuator

      • 配置屬性變化
      Old property New property
      endpoints.id.*management.endpoint.id.*
      endpoints.cors.*management.endpoints.web.cors.*
      endpoints.jmx.*management.endpoints.jmx.*
      management.addressmanagement.server.address
      management.context-pathmanagement.server.servlet.context-path
      management.ssl.*management.server.ssl.*
      management.portmanagement.server.port

      management.endpoints.web.base-path的默認(rèn)值為/actuator,即Actuator訪問(wèn)路徑前部增加了actuator([/actuator/health],[/actuator/info]),這可以在啟動(dòng)日志中看到。
      因management.security不再支持,權(quán)限配置需添加到WebSecurityConfigurerAdapter中:

      .authorizeRequests()
      .requestMatchers(EndpointRequest.to("health", "info")).permitAll()
      • Endpoint變化
      Endpoint Changes
      /actuatorNo longer available. There is, however, a mapping available at the root of management.endpoints.web.base-path that provides links to all the exposed endpoints.
      /auditeventsThe after parameter is no longer required
      /autoconfigRenamed to /conditions
      /docsNo longer available (the API documentation is part of the published documentation now)
      /healthRather than relying on the sensitive flag to figure out if the health endpoint had to show full details or not, there is now a management.endpoint.health.show-details option: never, always, when-authorized. By default, /actuator/health is exposed and details are not shown.
      /traceRenamed to /httptrace

      新特性

      • Configuration Property Binding

      可以在代碼中直接使用Binder API從配置文件中讀取內(nèi)容:

      public class Person implements EnvironmentAware {
              private Environment environment;
      
              @Override
              public void setEnvironment(Environment environment) {
                  this.environment = environment;
              }
      
              public void bind() {
                  List people = Binder.get(environment)
                  .bind("my.property", Bindable.listOf(PersonName.class))
                  .orElseThrow(IllegalStateException::new);
              }
      }

      YAML配置

      my:
        property:
        - first-name: Jane
          last-name: Doe
        - first-name: John
          last-name: Doe
      • Spring Data Web Configuration

      新增spring.data.web配置來(lái)設(shè)置分頁(yè)和排序:

      # DATA WEB (SpringDataWebProperties)
      spring.data.web.pageable.default-page-size=20 # Default page size.
      spring.data.web.pageable.max-page-size=2000 # Maximum page size to be accepted.
      spring.data.web.pageable.one-indexed-parameters=false # Whether to expose and assume 1-based page number indexes.
      spring.data.web.pageable.page-parameter=page # Page index parameter name.
      spring.data.web.pageable.prefix= # General prefix to be prepended to the page number and page size parameters.
      spring.data.web.pageable.qualifier-delimiter=_ # Delimiter to be used between the qualifier and the actual page number and size properties.
      spring.data.web.pageable.size-parameter=size # Page size parameter name.
      spring.data.web.sort.sort-parameter=sort # Sort parameter name.
      • 支持自定義JdbcTemplate
      # JDBC (JdbcProperties)
      spring.jdbc.template.fetch-size=-1 # Number of rows that should be fetched from the database when more rows are needed.
      spring.jdbc.template.max-rows=-1 # Maximum number of rows.
      spring.jdbc.template.query-timeout= # Query timeout. Default is to use the JDBC driver's default configuration. If a duration suffix is not specified, seconds will be used.
      • 支持hibernate自定義命名策略
      • Reactive

      更多新特性請(qǐng)查看Release Notes。

      Swagger

      
          io.springfox
          springfox-swagger2
          2.9.2
      
      
          io.springfox
          springfox-swagger-ui
          2.9.2
      

      Swagger 2.9版本,增加了對(duì)@ApiParam屬性example的處理,在Swagger UI和文檔中會(huì)顯示,因此要注意設(shè)置合適的example值:

      @ApiOperation(value = "Delete airline by id")
      @GetMapping("/airlines/delete/{airlineId}")
      public void deleteAirline(@ApiParam(required = true, example = "123") @PathVariable Long airlineId)

      否則你會(huì)看到Warn日志:
      AbstractSerializableParameter

      @JsonProperty("x-example")
      public Object getExample() {
          if (example == null) {
              return null;
          }
          try {
              if (BaseIntegerProperty.TYPE.equals(type)) {
                  return Long.valueOf(example);
              } else if (DecimalProperty.TYPE.equals(type)) {
                  return Double.valueOf(example);
              } else if (BooleanProperty.TYPE.equals(type)) {
                  if ("true".equalsIgnoreCase(example) || "false".equalsIgnoreCase(defaultValue)) {
                      return Boolean.valueOf(example);
                  }
              }
          } catch (NumberFormatException e) {
              LOGGER.warn(String.format("Illegal DefaultValue %s for parameter type %s", defaultValue, type), e);
          }
          return example;
      }

      另外Swagger 2.9.2會(huì)為org.springframework.data.domain.Pageable自動(dòng)增加@ApiImplicitParams。

      參考文檔

      Spring Boot Reference Guide 2.0.7.RELEASE
      Spring Boot 2.0 Migration Guide
      Spring Boot 2.0 Configuration Changelog
      Spring Boot 2.0 Release Notes
      Spring Boot Relaxed Binding 2.0

      另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。


      分享名稱(chēng):從SpringBoot1.5升級(jí)到2.0-創(chuàng)新互聯(lián)
      本文來(lái)源:http://ef60e0e.cn/article/cohjci.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        苏尼特右旗| 河间市| 尖扎县| 上林县| 赤城县| 安阳市| 邵武市| 奎屯市| 安乡县| 平顶山市| 云南省| 永泰县| 镇巴县| 邮箱| 洱源县| 普兰县| 靖江市| 融水| 宜城市| 普宁市| 天等县| 阜阳市| 宝清县| 辽宁省| 台北县| 兴宁市| 垫江县| 揭东县| 博湖县| 简阳市| 大兴区| 东乡县| 台州市| 保康县| 五华县| 建始县| 广汉市| 雷州市| 行唐县| 浮梁县| 牙克石市|