zoukankan      html  css  js  c++  java
  • SpringBoot学习(二)

    spring-boot-starter-parent

    Maven的用户可以通过继承spring-boot-starter-parent项目来获得一些合理的默认配置。这个parent提供了以下特性:

      • 默认使用Java 8
      • 使用UTF-8编码
      • 一个引用管理的功能,在dependencies里的部分配置可以不用填写version信息,这些version信息会从spring-boot-dependencies里得到继承。
      • 识别过来资源过滤(Sensible resource filtering.)
      • 识别插件的配置(Sensible plugin configuration (exec plugin, surefire, Git commit ID, shade).)
      • 能够识别application.properties和application.yml类型的文件,同时也能支持profile-specific类型的文件(如: application-foo.properties and application-foo.yml,这个功能可以更好的配置不同生产环境下的配置文件)。
      • maven把默认的占位符${…​}改为了@..@(这点大家还是看下原文自己理解下吧,我个人用的也比较少 
        since the default config files accept Spring style placeholders (${…​}) the Maven filtering is changed to use @..@ placeholders (you can override that with a Maven property resource.delimiter).)
      
      <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>

     

    spring boot web

     spring boot集成了servlet容器,当我们在pom文件中增加spring-boot-starter-web的maven依赖时,不做任何web相关的配置便能提供web服务,这还得归于spring boot 自动配置的功能(因为加了EnableAutoConfiguration的注解),帮我们创建了一堆默认的配置,以前在web.xml中配置,现在都可以通过spring bean的方式进行配置,由spring来进行生命周期的管理,大多数情况下,我们需要重载这些配置(例如修改服务的启动端口,contextpath,filter,listener,servlet,session超时时间等)

       <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency><!-- 不用写版本信息,会从spring-boot-dependencies里得到继承 -->

    spring boot starters

    包含各种starter

    详情https://blog.csdn.net/u014430366/article/details/53648139

    spring-boot-devtools

    是一个为开发者服务的一个模块,其中最重要的功能就是自动应用代码更改到最新的App上面去 

    <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
                <optional>true</optional>
            </dependency>


    spring-boot-autoconfigure

    自动配置

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency><!-- spring boot 自动配置需要的包 -->

      @Configuration可理解为用spring的时候xml里面的<beans>标签

      @Bean可理解为用spring的时候xml里面的<bean>标签

      详解请看https://blog.csdn.net/u012260707/article/details/52021265

  • 相关阅读:
    [LintCode] Flatten Nested List Iterator 压平嵌套链表迭代器
    [LintCode] Reverse Pairs 翻转对
    [CareerCup] 17.9 Word Frequency in a Book 书中单词频率
    [CareerCup] 17.8 Contiguous Sequence with Largest Sum 连续子序列之和最大
    [CareerCup] 17.7 English Phrase Describe Integer 英文单词表示数字
    [LeetCode] Reverse Vowels of a String 翻转字符串中的元音字母
    [CareerCup] 17.6 Sort Array 排列数组
    [LeetCode] 344. Reverse String 翻转字符串
    [CareerCup] 17.5 Game of Master Mind 猜字游戏
    [CareerCup] 17.4 Maximum of Two Numbers 两数中的较大值
  • 原文地址:https://www.cnblogs.com/goujh/p/8629208.html
Copyright © 2011-2022 走看看