Spring Boot 入門案例與配置說明

一.Spring Boot簡介

官網地址:http://spring.io/projects/spring-boothtml

Spring Boot能夠輕鬆建立能夠運行的獨立的,生產級的基於Spring的應用程序。咱們對Spring平臺和第三方庫進行了一種自覺得是的觀點,這樣您就能夠輕鬆上手了。大多數Spring Boot應用程序只須要不多的Spring配置。java

您可使用Spring Boot建立可使用java -jar或更傳統的war部署啓動的Java應用程序 咱們還提供了一個運行「spring腳本」的命令行工具。python

咱們的主要目標是:web

  • 爲全部Spring開發提供從根本上更快且可普遍訪問的入門體驗。
  • 開箱即用,但隨着需求開始偏離默認值而迅速擺脫困境。
  • 提供大型項目(例如嵌入式服務器,安全性,度量標準,運行情況檢查和外部化配置)通用的一系列非功能性功能。
  • 絕對沒有代碼生成,也不須要XML配置。

背景:spring

J2EE笨重的開發、繁多的配置、低下的開發效率、複雜的部署流程、第三方技術集成難度大。express

優勢:

快速建立獨立運行的Spring項目以及與主流框架集成apache

使用嵌入式的Servlet容器,應用無需打成WAR包json

starters自動依賴與版本控制api

大量的自動配置,簡化開發,也可修改默認值tomcat

無需配置XML,無代碼生成,開箱即用

準生產環境的運行時應用監控

與雲計算的自然集成

解決:

「Spring全家桶」時代。Spring Boot à J2EE一站式解決方案Spring Cloud à 分佈式總體解決方。

單體應用

微服務

二.Spring Boot入門

1. 環境準備

jdk1.8    

maven3.x

IntelliJ IDEA 2018

Spring Boot 2.0.5.RELEASE須要Java 8或9以及 Spring Framework 5.0.9.RELEASE或更高版本。

Spring Boot文檔參考指南 :https://docs.spring.io/spring-boot/docs/2.0.5.RELEASE/reference/htmlsingle/#getting-started-system-requirements-servlet-containers

2. 建立maven項目

編輯pom.xml文件,引入相關依賴

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xyg</groupId>
    <artifactId>spring-boot</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- 繼承自Spring Boot -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.5.RELEASE</version>
    </parent>

    <!-- 添加Web應用程序的典型依賴項 -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
<build> <plugins> <!-- 打包插件,打包成可執行jar包 --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>

3. 建立主程序引導類

package com.xyg;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Author: Mr.Deng
 * Date: 2018/9/14
 * Desc: @SpringBootConfiguration來標註一個主程序類,說明這是一個springboot應用
 */
@SpringBootApplication
public class HelloWorldApplication {

    public static void main(String[] args) {
        //springboot應用啓動起來,run方法裏第一個是應用主程序類名,第二個是應用參數
        SpringApplication.run(HelloWorldApplication.class,args);
    }
}

編寫Controller層Service

package com.xyg.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Author: Mr.Deng
 * Date: 2018/9/14
 * Desc: 編寫Controller層,發送hello請求
 */

@Controller
public class HelloController {

    @ResponseBody
    @RequestMapping("/hello")
    public String Hello(){
       return "Hello World!";
    }
}

4. 啓動程序測試

執行主程序裏的main方法,控制檯輸出以下信息

D:\Develop\Java\jdk1.8\bin\java "-javaagent:D:\IDEA\IntelliJ IDEA 2018.1\lib\idea_rt.jar=62470:D:\IDEA\IntelliJ IDEA 2018.1\bin" -Dfile.encoding=UTF-8 -classpath D:\Develop\Java\jdk1.8\jre\lib\charsets.jar;D:\Develop\Java\jdk1.8\jre\lib\deploy.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\access-bridge-64.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\cldrdata.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\dnsns.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\jaccess.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\jfxrt.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\localedata.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\nashorn.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\sunec.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\sunjce_provider.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\sunmscapi.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\sunpkcs11.jar;D:\Develop\Java\jdk1.8\jre\lib\ext\zipfs.jar;D:\Develop\Java\jdk1.8\jre\lib\javaws.jar;D:\Develop\Java\jdk1.8\jre\lib\jce.jar;D:\Develop\Java\jdk1.8\jre\lib\jfr.jar;D:\Develop\Java\jdk1.8\jre\lib\jfxswt.jar;D:\Develop\Java\jdk1.8\jre\lib\jsse.jar;D:\Develop\Java\jdk1.8\jre\lib\management-agent.jar;D:\Develop\Java\jdk1.8\jre\lib\plugin.jar;D:\Develop\Java\jdk1.8\jre\lib\resources.jar;D:\Develop\Java\jdk1.8\jre\lib\rt.jar;D:\IDEA\WorkSpace\spring-boot\target\classes;D:\Develop\maven\repository\org\springframework\boot\spring-boot-starter-web\2.0.5.RELEASE\spring-boot-starter-web-2.0.5.RELEASE.jar;D:\Develop\maven\repository\org\springframework\boot\spring-boot-starter\2.0.5.RELEASE\spring-boot-starter-2.0.5.RELEASE.jar;D:\Develop\maven\repository\org\springframework\boot\spring-boot\2.0.5.RELEASE\spring-boot-2.0.5.RELEASE.jar;D:\Develop\maven\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.5.RELEASE\spring-boot-autoconfigure-2.0.5.RELEASE.jar;D:\Develop\maven\repository\org\springframework\boot\spring-boot-starter-logging\2.0.5.RELEASE\spring-boot-starter-logging-2.0.5.RELEASE.jar;D:\Develop\maven\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\Develop\maven\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\Develop\maven\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;D:\Develop\maven\repository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;D:\Develop\maven\repository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;D:\Develop\maven\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;D:\Develop\maven\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;D:\Develop\maven\repository\org\springframework\spring-core\5.0.9.RELEASE\spring-core-5.0.9.RELEASE.jar;D:\Develop\maven\repository\org\springframework\spring-jcl\5.0.9.RELEASE\spring-jcl-5.0.9.RELEASE.jar;D:\Develop\maven\repository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;D:\Develop\maven\repository\org\springframework\boot\spring-boot-starter-json\2.0.5.RELEASE\spring-boot-starter-json-2.0.5.RELEASE.jar;D:\Develop\maven\repository\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;D:\Develop\maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;D:\Develop\maven\repository\com\fasterxml\jackson\core\jackson-core\2.9.6\jackson-core-2.9.6.jar;D:\Develop\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.6\jackson-datatype-jdk8-2.9.6.jar;D:\Develop\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.6\jackson-datatype-jsr310-2.9.6.jar;D:\Develop\maven\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.6\jackson-module-parameter-names-2.9.6.jar;D:\Develop\maven\repository\org\springframework\boot\spring-boot-starter-tomcat\2.0.5.RELEASE\spring-boot-starter-tomcat-2.0.5.RELEASE.jar;D:\Develop\maven\repository\org\apache\tomcat\embed\tomcat-embed-core\8.5.34\tomcat-embed-core-8.5.34.jar;D:\Develop\maven\repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.34\tomcat-embed-el-8.5.34.jar;D:\Develop\maven\repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.34\tomcat-embed-websocket-8.5.34.jar;D:\Develop\maven\repository\org\hibernate\validator\hibernate-validator\6.0.12.Final\hibernate-validator-6.0.12.Final.jar;D:\Develop\maven\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;D:\Develop\maven\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;D:\Develop\maven\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;D:\Develop\maven\repository\org\springframework\spring-web\5.0.9.RELEASE\spring-web-5.0.9.RELEASE.jar;D:\Develop\maven\repository\org\springframework\spring-beans\5.0.9.RELEASE\spring-beans-5.0.9.RELEASE.jar;D:\Develop\maven\repository\org\springframework\spring-webmvc\5.0.9.RELEASE\spring-webmvc-5.0.9.RELEASE.jar;D:\Develop\maven\repository\org\springframework\spring-aop\5.0.9.RELEASE\spring-aop-5.0.9.RELEASE.jar;D:\Develop\maven\repository\org\springframework\spring-context\5.0.9.RELEASE\spring-context-5.0.9.RELEASE.jar;D:\Develop\maven\repository\org\springframework\spring-expression\5.0.9.RELEASE\spring-expression-5.0.9.RELEASE.jar com.xyg.HelloWorldApplication

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.5.RELEASE)

2018-09-14 15:37:28.552  INFO 8120 --- [           main] com.xyg.HelloWorldApplication            : Starting HelloWorldApplication on DTX with PID 8120 (D:\IDEA\WorkSpace\spring-boot\target\classes started by Administrator in D:\IDEA\WorkSpace\spring-boot)
2018-09-14 15:37:28.558  INFO 8120 --- [           main] com.xyg.HelloWorldApplication            : No active profile set, falling back to default profiles: default
2018-09-14 15:37:28.953  INFO 8120 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@55040f2f: startup date [Fri Sep 14 15:37:28 CST 2018]; root of context hierarchy
2018-09-14 15:37:33.854  INFO 8120 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-09-14 15:37:34.001  INFO 8120 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-09-14 15:37:34.001  INFO 8120 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.34
2018-09-14 15:37:34.024  INFO 8120 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\Develop\Java\jdk1.8\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\Develop\maven\apache-maven-3.5.0/bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\NetSarang;D:\Develop\Java\jdk1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\Develop\secureCRT\;D:\Develop\SVN\VisualSVN Server\bin;D:\Develop\SVN\TortoiseSVN\bin;D:\usr\hadoop-2.7.6\bin;D:\usr\hadoop-2.7.6\sbin;D:\Python tools\python2.7.9;D:\scalaTools\scala\bin;D:\usr\spark-1.6.0-bin-hadoop2.6\bin;D:\usr\spark-1.6.0-bin-hadoop2.6sbin;D:\Python tools\python3.6.5;D:\Python tools\python2.7.9;D:\Python tools\python2.7.9\Scripts;D:\Python tools\python3.6.5\Scripts;D:\Develop\Git\cmd;D:\Develop\Git\TortoiseGit\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;;.]
2018-09-14 15:37:34.291  INFO 8120 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-09-14 15:37:34.292  INFO 8120 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 5347 ms
2018-09-14 15:37:34.470  INFO 8120 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-09-14 15:37:34.479  INFO 8120 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-09-14 15:37:34.480  INFO 8120 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-09-14 15:37:34.480  INFO 8120 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-09-14 15:37:34.480  INFO 8120 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-09-14 15:37:34.840  INFO 8120 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-14 15:37:35.146  INFO 8120 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@55040f2f: startup date [Fri Sep 14 15:37:28 CST 2018]; root of context hierarchy
2018-09-14 15:37:35.373  INFO 8120 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello]}" onto public java.lang.String com.xyg.controller.HelloController.Hello()
2018-09-14 15:37:35.382  INFO 8120 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-09-14 15:37:35.385  INFO 8120 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-09-14 15:37:35.451  INFO 8120 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-14 15:37:35.451  INFO 8120 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-09-14 15:37:35.901  INFO 8120 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-09-14 15:37:35.992  INFO 8120 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2018-09-14 15:37:36.005  INFO 8120 --- [           main] com.xyg.HelloWorldApplication            : Started HelloWorldApplication in 8.445 seconds (JVM running for 9.814)

經過查看日誌信息發現tomcat:8080 啓動,頁面輸入:  http://localhost:8080/hello ,

5.  部署服務

package打包jar在target目錄,拷貝到左面,而後進入jar包所在目錄,執行命令 java -jar  xxx.jar ,頁面訪問

6.  POM文件解析

1)spring boot 版本仲裁中心

<parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.5.RELEASE</version>
</parent>
它的父項目依賴
<parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-dependencies</artifactId>
      <version>2.0.5.RELEASE</version>
      <relativePath>../../spring-boot-dependencies</relativePath>
</parent>
他來真正管理spring boot應用裏面全部的依賴版本,這裏面定義了不少服務版本,當裏面定義了服務版本時,咱們就不須要再導入相關依賴,沒有定義時,需手工導入依賴。

1)spring boot 場景啓動器,幫咱們導入web模塊正常運行所依賴的組件。

<dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>
</dependency>
它的父模塊來自
<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starters</artifactId>
   <version>2.0.5.RELEASE</version>
</parent>
它的父模塊來自
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-parent</artifactId>
  <version>2.0.5.RELEASE</version>
  <relativePath>../spring-boot-parent</relativePath>
</parent>
它的父模塊來自
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-dependencies</artifactId>
  <version>2.0.5.RELEASE</version>
  <relativePath>../spring-boot-dependencies</relativePath>
</parent>

spring boot 將全部的功能場景都抽取出來,作成一個個的starters(啓動器),只須要在項目裏引入相關的starter,相關場景的全部依賴都會導入進來。

7.@SpringBootApplication

Spring Boot應用標註在某個類上說明這個類是SpringBoot的主配置類,

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(
    excludeFilters = {@Filter(
    type = FilterType.CUSTOM,
    classes = {TypeExcludeFilter.class}
), @Filter(
    type = FilterType.CUSTOM,
    classes = {AutoConfigurationExcludeFilter.class}
)}
)
public @interface SpringBootApplication {

@SpringBootConfiguration:Spring Boot的配置類; 標註在某個類上,表示這是一個Spring   Boot的配置類;

@Configuration:配置類上來標註這個註解;配置類 ----- 配置文件;配置類也是容器中的一個組件;@Component

@EnableAutoConfiguration:開啓自動配置功能;之前咱們須要配置的東西,SpringBoot幫咱們自動配置;這個註解告訴SpringBoot開啓自動配置功能;這樣自動配置才能生效;

@AutoConfigurationPackage
@Import(EnableAutoConfigurationImportSelector.class)
public  @interface  EnableAutoConfiguration  {

@AutoConfigurationPackage:自動配置包@Import(AutoConfigurationPackages.Registrar.class):

Spring的底層註解@Import,給容器中導入一個組件;導入的組件由AutoConfigurationPackages.Registrar.class;

將主配置類(@SpringBootApplication標註的類)的所在包及下面全部子包裏面的全部組件掃描到Spring容器;

@Import(EnableAutoConfigurationImportSelector.class) 給容器中導入組件?

EnableAutoConfigurationImportSelector:導入哪些組件的選擇器;

將全部須要導入的組件以全類名的方式返回;這些組件就會被添加到容器中;

會給容器中導入很是多的自動配置類(xxxAutoConfiguration);就是給容器中導入這個場景須要的全部組件, 並配置好這些組件;

有了自動配置類,免去了咱們手動編寫配置注入功能組件等的工做;

SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class,classLoader);

Spring Boot在啓動的時候從類路徑下的META-INF/spring.factories中獲取EnableAutoConfiguration指定的值,將些值做爲自動配置類導入到容器中,自動配置類就生效,幫咱們進行自動配置工做;之前咱們須要本身配置的東      西,自動配置類都幫咱們;

J2EE的總體整合解決方案和自動配置都在spring-boot-autoconfigure-2.0.5.RELEASE.jar;

8.springboot嚮導建立

(前提條件-聯網條件下)快速建立一個spring boot項目,new project

點擊flish完成項目建立,把下面不用的幾項刪除掉

而後編寫controller層代碼測試(略)

三.配置文件

1.application.properties

resource裏面有三個文件,application.properties  或者  application.yml ,二者的書寫格式不同,爲SpringBoot的全局配置文件,配置文件名是固定的,

配置文件的做用:修改SpringBoot自動配置的默認值;SpringBoot在底層都給咱們自動配置好;

2.static

靜態資源都放在這個包下 

3.templates

模板 

四.日誌框架

SpringBoot默認選用 SLF4jlogback

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring‐boot‐starter‐logging</artifactId>
</dependency>

給類路徑下放上每一個日誌框架本身的配置文件便可;SpringBoot就不使用他默認配置的了

Logging System Customization

Logback

logback-spring.xmllogback-spring.groovylogback.xml, or logback.groovy

Log4j2

log4j2-spring.xml or log4j2.xml

JDK (Java Util Logging)

logging.properties

logback.xml:直接就被日誌框架識別了;logback-spring.xml:日誌框架就不直接加載日誌的配置項,由SpringBoot解析日誌配置,可使用SpringBoot的高級Profile功能。

相關文章
相關標籤/搜索