application.properties 檔案和 application.yml 檔案有什麼區別呢?

來源:互聯網
上載者:User

標籤:apache   dstat   mod   nat   java ee   AC   select   執行   檔案的   

application.properties  檔案和 application.yml 檔案有什麼區別呢?

yml檔案的好處,天然的樹狀結構,一目瞭然,實質上跟properties是差不多的。

官方給的很多demo,都是用yml檔案配置的。

注意點:

1,原有的key,例如spring.jpa.properties.hibernate.dialect,按“.”分割,都變成樹狀的配置

2,key後面的冒號,後面一定要跟一個空格

3,把原有的application.properties刪掉。然後一定要執行一下  maven -X clean install

 

#application.ymlserver:  port: 8086  spring:    datasource:        name: test        url: jdbc:mysql://192.168.1.112:3306/test        username: root        password: xxx        # 使用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
#application.propertiesserver.port=8085spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSourcespring.datasource.url=jdbc:mysql://aliyuncs.com:3306/home?useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=truespring.datasource.username=rootspring.datasource.password=***spring.datasource.driver-class-name=com.mysql.jdbc.Driver#mybatis.mapper-locations=classpath*:com/wanyu/fams/mapping/*Mapper.xml#mybatis.type-aliases-package=com.wanyu.fams.modelspring.mvc.view.prefix=/WEB-INF/jsp/spring.mvc.view.suffix=.jspspring.druid.datasource.type=com.alibaba.druid.pool.DruidDataSourcespring.druid.datasource.driverClassName=com.mysql.jdbc.Driverspring.druid.datasource.url=jdbc:mysql://localhost:3306/spring_boot?characterEncoding=utf-8spring.druid.datasource.username=rootspring.druid.datasource.password=xxx

 

application.properties 檔案和 application.yml 檔案有什麼區別呢?

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.