1. 程式人生 > >【Spring Boot學習總結】6.SpringBoot全域性配置檔案

【Spring Boot學習總結】6.SpringBoot全域性配置檔案

上一篇我們總結了SpringBoot的核心註解以及一些簡單的配置,本篇我們來了解SpringBoot的全域性配置檔案。

Spring Boot專案使用一個全域性配置檔案application.properties或者是application.yml,在resource目錄下或者類路徑下的/config下、一般開發中我們放置在resource下。

我們下面就在之前的測試工程中新增一個全域性配置檔案。開啟工程,在resource資料夾下建立一個名為“application.properties”的檔案:

記得我們建立Spring Boot工程的時候,內建的Tomcat預設埠為8080,有時候我們需要重新制定埠,使用“server.port”就可以制定內建Tomcat容器的埠:
server.port=8088
我們這裡將埠改為了8088,重啟專案,發現已經改變:


訪問服務也是在8088埠:

然後我們也可以修改Spring MVC的DispatchServlet的響應規則,預設是匹配所有請求路徑的,這裡我們改為所有請求以“html”結尾才被響應:
server.servlet-path=*.html
我們依然訪問原來的地址,發現找不到資訊:

帶有html字尾就可以正常響應:

對於全域性變數的配置,Spring Boot的官方給了我們一個比較完整的配置大全:
application.properties(下載超連結:https://download.csdn.net/download/u013517797/10613303)
大家可以進行配置參考,但是註釋是純英文的,需要一些英文功底。
下面是我總結的一些常見的、重要的配置,後面以中文進行解釋,方便大家參考:
(1)mvc相關的一些配置


mvc
spring.mvc.async.request-timeout設定async請求的超時時間,以毫秒為單位,如果沒有設定的話,以具體實現的超時時間為準,比如tomcat的servlet3的話是10秒.

spring.mvc.date-format設定日期的格式,比如dd/MM/yyyy.

spring.mvc.favicon.enabled是否支援favicon.ico,預設為: true

spring.mvc.ignore-default-model-on-redirect在重定向時是否忽略預設model的內容,預設為true

spring.mvc.locale指定使用的Locale.

spring.mvc.message-codes-resolver-format指定message codes的格式化策略(PREFIX_ERROR_CODE,POSTFIX_ERROR_CODE).

spring.mvc.view.prefix指定mvc檢視的字首.

spring.mvc.view.suffix指定mvc檢視的字尾.

messages
spring.messages.basename指定message的basename,多個以逗號分隔,如果不加包名的話,預設從classpath路徑開始,預設: messages

spring.messages.cache-seconds設定載入的資原始檔快取失效時間,-1的話為永不過期,預設為-1

spring.messages.encoding設定Message bundles的編碼,預設: UTF-8

mobile
spring.mobile.devicedelegatingviewresolver.enable-fallback是否支援fallback的解決方案,預設false

spring.mobile.devicedelegatingviewresolver.enabled是否開始device view resolver,預設為: false

spring.mobile.devicedelegatingviewresolver.mobile-prefix設定mobile端檢視的字首,預設為:mobile/

spring.mobile.devicedelegatingviewresolver.mobile-suffix設定mobile檢視的字尾

spring.mobile.devicedelegatingviewresolver.normal-prefix設定普通裝置的檢視字首

spring.mobile.devicedelegatingviewresolver.normal-suffix設定普通裝置檢視的字尾

spring.mobile.devicedelegatingviewresolver.tablet-prefix設定平板裝置檢視字首,預設:tablet/

spring.mobile.devicedelegatingviewresolver.tablet-suffix設定平板裝置檢視字尾.

spring.mobile.sitepreference.enabled是否啟用SitePreferenceHandler,預設為: true

view
spring.view.prefix設定mvc檢視的字首.

spring.view.suffix設定mvc檢視的字尾.

resource
spring.resources.add-mappings是否開啟預設的資源處理,預設為true

spring.resources.cache-period設定資源的快取時效,以秒為單位.

spring.resources.chain.cache是否開啟快取,預設為: true

spring.resources.chain.enabled是否開啟資源 handling chain,預設為false

spring.resources.chain.html-application-cache是否開啟h5應用的cache manifest重寫,預設為: false

spring.resources.chain.strategy.content.enabled是否開啟內容版本策略,預設為false

spring.resources.chain.strategy.content.paths指定要應用的版本的路徑,多個以逗號分隔,預設為:[/**]

spring.resources.chain.strategy.fixed.enabled是否開啟固定的版本策略,預設為false

spring.resources.chain.strategy.fixed.paths指定要應用版本策略的路徑,多個以逗號分隔

spring.resources.chain.strategy.fixed.version指定版本策略使用的版本號

spring.resources.static-locations指定靜態資源路徑,預設為classpath:[/META-INF/resources/,/resources/, /static/, /public/]以及context:/

multipart
multipart.enabled是否開啟檔案上傳支援,預設為true

multipart.file-size-threshold設定檔案寫入磁碟的閾值,單位為MB或KB,預設為0

multipart.location指定檔案上傳路徑.

multipart.max-file-size指定檔案大小最大值,預設1MB

multipart.max-request-size指定每次請求的最大值,預設為10MB

freemarker
spring.freemarker.allow-request-override指定HttpServletRequest的屬性是否可以覆蓋controller的model的同名項

spring.freemarker.allow-session-override指定HttpSession的屬性是否可以覆蓋controller的model的同名項

spring.freemarker.cache是否開啟template caching.

spring.freemarker.charset設定Template的編碼.

spring.freemarker.check-template-location是否檢查templates路徑是否存在.

spring.freemarker.content-type設定Content-Type.

spring.freemarker.enabled是否允許mvc使用freemarker.

spring.freemarker.expose-request-attributes設定所有request的屬性在merge到模板的時候,是否要都新增到model中.

spring.freemarker.expose-session-attributes設定所有HttpSession的屬性在merge到模板的時候,是否要都新增到model中.

spring.freemarker.expose-spring-macro-helpers設定是否以springMacroRequestContext的形式暴露RequestContext給Spring’s macro library使用

spring.freemarker.prefer-file-system-access是否優先從檔案系統載入template,以支援熱載入,預設為true

spring.freemarker.prefix設定freemarker模板的字首.

spring.freemarker.request-context-attribute指定RequestContext屬性的名.

spring.freemarker.settings設定FreeMarker keys.

spring.freemarker.suffix設定模板的字尾.

spring.freemarker.template-loader-path設定模板的載入路徑,多個以逗號分隔,預設: ["classpath:/templates/"]

spring.freemarker.view-names指定使用模板的檢視列表.

velocity
spring.velocity.allow-request-override指定HttpServletRequest的屬性是否可以覆蓋controller的model的同名項

spring.velocity.allow-session-override指定HttpSession的屬性是否可以覆蓋controller的model的同名項

spring.velocity.cache是否開啟模板快取

spring.velocity.charset設定模板編碼

spring.velocity.check-template-location是否檢查模板路徑是否存在.

spring.velocity.content-type設定ContentType的值

spring.velocity.date-tool-attribute設定暴露給velocity上下文使用的DateTool的名

spring.velocity.enabled設定是否允許mvc使用velocity

spring.velocity.expose-request-attributes是否在merge模板的時候,將request屬性都新增到model中

spring.velocity.expose-session-attributes是否在merge模板的時候,將HttpSession屬性都新增到model中

spring.velocity.expose-spring-macro-helpers設定是否以springMacroRequestContext的名來暴露RequestContext給Spring’s macro類庫使用

spring.velocity.number-tool-attribute設定暴露給velocity上下文的NumberTool的名

spring.velocity.prefer-file-system-access是否優先從檔案系統載入模板以支援熱載入,預設為true

spring.velocity.prefix設定velocity模板的字首.

spring.velocity.properties設定velocity的額外屬性.

spring.velocity.request-context-attribute設定RequestContext attribute的名.

spring.velocity.resource-loader-path設定模板路徑,預設為: classpath:/templates/

spring.velocity.suffix設定velocity模板的字尾.

spring.velocity.toolbox-config-location設定Velocity Toolbox配置檔案的路徑,比如 /WEB-INF/toolbox.xml.

spring.velocity.view-names設定需要解析的檢視名稱.

thymeleaf
spring.thymeleaf.cache是否開啟模板快取,預設true

spring.thymeleaf.check-template-location是否檢查模板路徑是否存在,預設true

spring.thymeleaf.content-type指定Content-Type,預設為: text/html

spring.thymeleaf.enabled是否允許MVC使用Thymeleaf,預設為: true

spring.thymeleaf.encoding指定模板的編碼,預設為: UTF-8

spring.thymeleaf.excluded-view-names指定不使用模板的檢視名稱,多個以逗號分隔.

spring.thymeleaf.mode指定模板的模式,具體檢視StandardTemplateModeHandlers,預設為: HTML5

spring.thymeleaf.prefix指定模板的字首,預設為:classpath:/templates/

spring.thymeleaf.suffix指定模板的字尾,預設為:.html

spring.thymeleaf.template-resolver-order指定模板的解析順序,預設為第一個.

spring.thymeleaf.view-names指定使用模板的檢視名,多個以逗號分隔.

mustcache
spring.mustache.cache是否Enable template caching.

spring.mustache.charset指定Template的編碼.

spring.mustache.check-template-location是否檢查預設的路徑是否存在.

spring.mustache.content-type指定Content-Type.

spring.mustache.enabled是否開啟mustcache的模板支援.

spring.mustache.prefix指定模板的字首,預設: classpath:/templates/

spring.mustache.suffix指定模板的字尾,預設: .html

spring.mustache.view-names指定要使用模板的檢視名.

groovy模板
spring.groovy.template.allow-request-override指定HttpServletRequest的屬性是否可以覆蓋controller的model的同名項

spring.groovy.template.allow-session-override指定HttpSession的屬性是否可以覆蓋controller的model的同名項

spring.groovy.template.cache是否開啟模板快取.

spring.groovy.template.charset指定Template編碼.

spring.groovy.template.check-template-location是否檢查模板的路徑是否存在.

spring.groovy.template.configuration.auto-escape是否在渲染模板時自動排查model的變數,預設為: false

spring.groovy.template.configuration.auto-indent是否在渲染模板時自動縮排,預設為false

spring.groovy.template.configuration.auto-indent-string如果自動縮排啟用的話,是使用SPACES還是TAB,預設為: SPACES

spring.groovy.template.configuration.auto-new-line渲染模板時是否要輸出換行,預設為false

spring.groovy.template.configuration.base-template-class指定template base class.

spring.groovy.template.configuration.cache-templates是否要快取模板,預設為true

spring.groovy.template.configuration.declaration-encoding在寫入declaration header時使用的編碼

spring.groovy.template.configuration.expand-empty-elements
是使用<br/>這種形式,還是<br></br>這種展開模式,預設為: false)

spring.groovy.template.configuration.locale指定template locale.

spring.groovy.template.configuration.new-line-string當啟用自動換行時,換行的輸出,預設為系統的line.separator屬性的值

spring.groovy.template.configuration.resource-loader-path指定groovy的模板路徑,預設為classpath:/templates/

spring.groovy.template.configuration.use-double-quotes指定屬性要使用雙引號還是單引號,預設為false

spring.groovy.template.content-type指定Content-Type.

spring.groovy.template.enabled是否開啟groovy模板的支援.

spring.groovy.template.expose-request-attributes設定所有request的屬性在merge到模板的時候,是否要都新增到model中.

spring.groovy.template.expose-session-attributes設定所有request的屬性在merge到模板的時候,是否要都新增到model中.

spring.groovy.template.expose-spring-macro-helpers設定是否以springMacroRequestContext的形式暴露RequestContext給Spring’s macro library使用

spring.groovy.template.prefix指定模板的字首.

spring.groovy.template.request-context-attribute指定RequestContext屬性的名.

spring.groovy.template.resource-loader-path指定模板的路徑,預設為: classpath:/templates/

spring.groovy.template.suffix指定模板的字尾

spring.groovy.template.view-names指定要使用模板的檢視名稱.

http
spring.hateoas.apply-to-primary-object-mapper設定是否對object mapper也支援HATEOAS,預設為: true

spring.http.converters.preferred-json-mapper是否優先使用JSON mapper來轉換.

spring.http.encoding.charset指定http請求和相應的Charset,預設: UTF-8

spring.http.encoding.enabled是否開啟http的編碼支援,預設為true

spring.http.encoding.force是否強制對http請求和響應進行編碼,預設為true

json
spring.jackson.date-format指定日期格式,比如yyyy-MM-dd HH:mm:ss,或者具體的格式化類的全限定名

spring.jackson.deserialization是否開啟Jackson的反序列化

spring.jackson.generator是否開啟json的generators.

spring.jackson.joda-date-time-format指定Joda date/time的格式,比如yyyy-MM-dd HH:mm:ss). 如果沒有配置的話,dateformat會作為backup

spring.jackson.locale指定json使用的Locale.

spring.jackson.mapper是否開啟Jackson通用的特性.

spring.jackson.parser是否開啟jackson的parser特性.

spring.jackson.property-naming-strategy指定PropertyNamingStrategy (CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)或者指定PropertyNamingStrategy子類的全限定類名.

spring.jackson.serialization是否開啟jackson的序列化.

spring.jackson.serialization-inclusion指定序列化時屬性的inclusion方式,具體檢視JsonInclude.Include列舉.

spring.jackson.time-zone指定日期格式化時區,比如America/Los_Angeles或者GMT+10.

jersey
spring.jersey.filter.order指定Jersey filter的order,預設為: 0

spring.jersey.init指定傳遞給Jersey的初始化引數.

spring.jersey.type指定Jersey的整合型別,可以是servlet或者filter.

(2)server伺服器相關的一些配置
server.address指定server繫結的地址

server.compression.enabled是否開啟壓縮,預設為false.

server.compression.excluded-user-agents指定不壓縮的user-agent,多個以逗號分隔,預設值為:text/html,text/xml,text/plain,text/css

server.compression.mime-types指定要壓縮的MIME type,多個以逗號分隔.

server.compression.min-response-size執行壓縮的閾值,預設為2048

server.context-parameters.[param name]設定servlet context 引數

server.context-path設定應用的context-path.

server.display-name設定應用的展示名稱,預設: application

server.jsp-servlet.class-name設定編譯JSP用的servlet,預設: org.apache.jasper

.servlet.JspServlet)

server.jsp-servlet.init-parameters.[param name]設定JSP servlet 初始化引數.

server.jsp-servlet.registered設定JSP servlet是否註冊到內嵌的servlet容器,預設true

server.port設定http監聽埠

server.servlet-path設定dispatcher servlet的監聽路徑,預設為: /

cookie、session配置
server.session.cookie.comment指定session cookie的comment

server.session.cookie.domain指定session cookie的domain

server.session.cookie.http-only是否開啟HttpOnly.

server.session.cookie.max-age設定session cookie的最大age.

server.session.cookie.name設定Session cookie 的名稱.

server.session.cookie.path設定session cookie的路徑.

server.session.cookie.secure設定session cookie的“Secure” flag.

server.session.persistent重啟時是否持久化session,預設false

server.session.timeoutsession的超時時間

server.session.tracking-modes設定Session的追蹤模式(cookie, url, ssl).

ssl配置
server.ssl.ciphers是否支援SSL ciphers.

server.ssl.client-auth設定client authentication是wanted 還是 needed.

server.ssl.enabled是否開啟ssl,預設: true

server.ssl.key-alias設定key store中key的別名.

server.ssl.key-password訪問key store中key的密碼.

server.ssl.key-store設定持有SSL certificate的key store的路徑,通常是一個.jks檔案.

server.ssl.key-store-password設定訪問key store的密碼.

server.ssl.key-store-provider設定key store的提供者.

server.ssl.key-store-type設定key store的型別.

server.ssl.protocol使用的SSL協議,預設: TLS

server.ssl.trust-store持有SSL certificates的Trust store.

server.ssl.trust-store-password訪問trust store的密碼.

server.ssl.trust-store-provider設定trust store的提供者.

server.ssl.trust-store-type指定trust store的型別.

tomcat
server.tomcat.access-log-enabled是否開啟access log ,預設: false)

server.tomcat.access-log-pattern設定access logs的格式,預設: common

server.tomcat.accesslog.directory設定log的目錄,預設: logs

server.tomcat.accesslog.enabled是否開啟access log,預設: false

server.tomcat.accesslog.pattern設定access logs的格式,預設: common

server.tomcat.accesslog.prefix設定Log 檔案的字首,預設: access_log

server.tomcat.accesslog.suffix設定Log 檔案的字尾,預設: .log

server.tomcat.background-processor-delay後臺執行緒方法的Delay大小: 30

server.tomcat.basedir設定Tomcat的base 目錄,如果沒有指定則使用臨時目錄.

server.tomcat.internal-proxies設定信任的正則表示式,預設:“10\.\d{1,3}\.\d{1,3}\.\d{1,3}| 192\.168\.\d{1,3}\.\d{1,3}| 169\.254\.\d{1,3}\.\d{1,3}| 127\.\d{1,3}\.\d{1,3}\.\d{1,3}| 172\.1[6-9]{1}\.\d{1,3}\.\d{1,3}| 172\.2[0-9]{1}\.\d{1,3}\.\d{1,3}|172\.3[0-1]{1}\.\d{1,3}\.\d{1,3}”

server.tomcat.max-http-header-size設定http header的最小值,預設: 0

server.tomcat.max-threads設定tomcat的最大工作執行緒數,預設為: 0

server.tomcat.port-header設定http header使用的,用來覆蓋原來port的value.

server.tomcat.protocol-header設定Header包含的協議,通常是 X-Forwarded-Proto,如果remoteIpHeader有值,則將設定為RemoteIpValve.

server.tomcat.protocol-header-https-value設定使用SSL的header的值,預設https.

server.tomcat.remote-ip-header設定remote IP的header,如果remoteIpHeader有值,則設定為RemoteIpValve

server.tomcat.uri-encoding設定URI的解碼字符集.

undertow
server.undertow.access-log-dir設定Undertow access log 的目錄,預設: logs

server.undertow.access-log-enabled是否開啟access log,預設: false

server.undertow.access-log-pattern設定access logs的格式,預設: common

server.undertow.accesslog.dir設定access log 的目錄.

server.undertow.buffer-size設定buffer的大小.

server.undertow.buffers-per-region設定每個region的buffer數

server.undertow.direct-buffers設定堆外記憶體

server.undertow.io-threads設定I/O執行緒數.

server.undertow.worker-threads設定工作執行緒數

(3)DataSource資料來源相關配置
spring.dao.exceptiontranslation.enabled是否開啟PersistenceExceptionTranslationPostProcessor,預設為true

spring.datasource.abandon-when-percentage-full設定超時被廢棄的連線佔到多少比例時要被關閉或上報

spring.datasource.allow-pool-suspension使用Hikari pool時,是否允許連線池暫停,預設為: false

spring.datasource.alternate-username-allowed是否允許替代的使用者名稱.

spring.datasource.auto-commit指定updates是否自動提交.

spring.datasource.catalog指定預設的catalog.

spring.datasource.commit-on-return設定當連線被歸還時,是否要提交所有還未完成的事務

spring.datasource.connection-init-sql指定連線被建立,再被新增到連線池之前執行的sql.

spring.datasource.connection-init-sqls使用DBCP connection pool時,指定初始化時要執行的sql

spring.datasource.connection-properties.[key]在使用DBCP connection pool時指定要配置的屬性

spring.datasource.connection-test-query指定校驗連接合法性執行的sql語句

spring.datasource.connection-timeout指定連線的超時時間,毫秒單位.

spring.datasource.continue-on-error在初始化資料庫時,遇到錯誤是否繼續,預設false

spring.datasource.data指定Data (DML)指令碼

spring.datasource.data-source-class-name指定資料來源的全限定名.

spring.datasource.data-source-jndi指定jndi的地址

spring.datasource.data-source-properties.[key]使用Hikari connection pool時,指定要設定的屬性

spring.datasource.db-properties使用Tomcat connection pool,指定要設定的屬性

spring.datasource.default-auto-commit是否自動提交.

spring.datasource.default-catalog指定連線預設的catalog.

spring.datasource.default-read-only是否設定預設連線只讀.

spring.datasource.default-transaction-isolation指定連線的事務的預設隔離級別.

spring.datasource.driver-class-name指定driver的類名,預設從jdbc url中自動探測.

spring.datasource.fair-queue是否採用FIFO返回連線.

spring.datasource.health-check-properties.[key]使用Hikari connection pool時,在心跳檢查時傳遞的屬性

spring.datasource.idle-timeout指定連線多久沒被使用時,被設定為空閒,預設為10ms

spring.datasource.ignore-exception-on-pre-load當初始化連線池時,是否忽略異常.

spring.datasource.init-sql當連線建立時,執行的sql

spring.datasource.initial-size指定啟動連線池時,初始建立的連線數量

spring.datasource.initialization-fail-fast當建立連線池時,沒法建立指定最小連線數量是否拋異常

spring.datasource.initialize指定初始化資料來源,是否用data.sql來初始化,預設: true

spring.datasource.isolate-internal-queries指定內部查詢是否要被隔離,預設為false

spring.datasource.jdbc-interceptors使用Tomcat connection pool時,指定jdbc攔截器,分號分隔

spring.datasource.jdbc-url指定JDBC URL.

spring.datasource.jmx-enabled是否開啟JMX,預設為: false

spring.datasource.jndi-name指定jndi的名稱.

spring.datasource.leak-detection-threshold使用Hikari connection pool時,多少毫秒檢測一次連線洩露.

spring.datasource.log-abandoned使用DBCP connection pool,是否追蹤廢棄statement或連線,預設為: false

spring.datasource.log-validation-errors當使用Tomcat connection pool是否列印校驗錯誤.

spring.datasource.login-timeout指定連線資料庫的超時時間.

spring.datasource.max-active指定連線池中最大的活躍連線數.

spring.datasource.max-age指定連線池中連線的最大年齡

spring.datasource.max-idle指定連線池最大的空閒連線數量.

spring.datasource.max-lifetime指定連線池中連線的最大生存時間,毫秒單位.

spring.datasource.max-open-prepared-statements指定最大的開啟的prepared statements數量.

spring.datasource.max-wait指定連線池等待連線返回的最大等待時間,毫秒單位.

spring.datasource.maximum-pool-size指定連線池最大的連線數,包括使用中的和空閒的連線.

spring.datasource.min-evictable-idle-time-millis指定一個空閒連線最少空閒多久後可被清除.

spring.datasource.min-idle指定必須保持連線的最小值(For DBCP and Tomcat connection pools)

spring.datasource.minimum-idle指定連線維護的最小空閒連線數,當使用HikariCP時指定.

spring.datasource.name指定資料來源名.

spring.datasource.num-tests-per-eviction-run指定執行每個idle object evictor執行緒時的物件數量

spring.datasource.password指定資料庫密碼.

spring.datasource.platform指定schema要使用的Platform(schema-${platform}.sql),預設為: all

spring.datasource.pool-name指定連線池名字.

spring.datasource.pool-prepared-statements指定是否池化statements.

spring.datasource.propagate-interrupt-state在等待連線時,如果執行緒被中斷,是否傳播中斷狀態.

spring.datasource.read-only當使用Hikari connection pool時,是否標記資料來源只讀

spring.datasource.register-mbeans指定Hikari connection pool是否註冊JMX MBeans.

spring.datasource.remove-abandoned指定當連線超過廢棄超時時間時,是否立刻刪除該連線.

spring.datasource.remove-abandoned-timeout指定連線應該被廢棄的時間.

spring.datasource.rollback-on-return在歸還連線時,是否回滾等待中的事務.

spring.datasource.schema指定Schema (DDL)指令碼.

spring.datasource.separator指定初始化指令碼的語句分隔符,預設: ;

spring.datasource.sql-script-encoding指定SQL scripts編碼.

spring.datasource.suspect-timeout指定列印廢棄連線前的超時時間.

spring.datasource.test-on-borrow當從連線池借用連線時,是否測試該連線.

spring.datasource.test-on-connect建立時,是否測試連線

spring.datasource.test-on-return在連線歸還到連線池時是否測試該連線.

spring.datasource.test-while-idle當連線空閒時,是否執行連線測試.

spring.datasource.time-between-eviction-runs-millis指定空閒連線檢查、廢棄連線清理、空閒連線池大小調整之間的操作時間間隔

spring.datasource.transaction-isolation指定事務隔離級別,使用Hikari connection pool時指定

spring.datasource.url指定JDBC URL.

spring.datasource.use-disposable-connection-facade是否對連線進行包裝,防止連線關閉之後被使用.

spring.datasource.use-equals比較方法名時是否使用String.equals()替換==.

spring.datasource.use-lock是否對連線操作加鎖

spring.datasource.username指定資料庫名.

spring.datasource.validation-interval指定多少ms執行一次連線校驗.

spring.datasource.validation-query指定獲取連線時連線校驗的sql查詢語句.

spring.datasource.validation-query-timeout指定連線校驗查詢的超時時間.

spring.datasource.validation-timeout設定連線校驗的超時時間,當使用Hikari connection pool時指定

spring.datasource.validator-class-name用來測試查詢的validator全限定名.

spring.datasource.xa.data-source-class-name指定資料來源的全限定名.

spring.datasource.xa.properties指定傳遞給XA data source的屬性

JPA
spring.jpa.database指定目標資料庫.

spring.jpa.database-platform指定目標資料庫的型別.

spring.jpa.generate-ddl是否在啟動時初始化schema,預設為false

spring.jpa.hibernate.ddl-auto指定DDL mode (none, validate, update, create, create-drop). 當使用內嵌資料庫時,預設是create-drop,否則為none.

spring.jpa.hibernate.naming-strategy指定命名策略.

spring.jpa.open-in-view是否註冊OpenEntityManagerInViewInterceptor,繫結JPA EntityManager到請求執行緒中,預設為: true

spring.jpa.properties新增額外的屬性到JPA provider.

spring.jpa.show-sql是否開啟sql的log,預設為: false

jooq
spring.jooq.sql-dialect指定JOOQ使用的SQLDialect,比如POSTGRES.

h2
spring.h2.console.enabled是否開啟控制檯,預設為false

spring.h2.console.path指定控制檯路徑,預設為: /h2-console

JTA
spring.jta.allow-multiple-lrc是否允許 multiple LRC,預設為: false

spring.jta.asynchronous2-pc指定兩階段提交是否可以非同步,預設為: false

spring.jta.background-recovery-interval指定多少分鐘跑一次recovery process,預設為: 1

spring.jta.background-recovery-interval-seconds指定多久跑一次recovery process,預設: 60

spring.jta.current-node-only-recovery是否過濾掉其他非本JVM的recovery,預設為: true

spring.jta.debug-zero-resource-transaction是否追蹤沒有使用指定資源的事務,預設為: false

spring.jta.default-transaction-timeout設定預設的事務超時時間,預設為60

spring.jta.disable-jmx是否禁用jmx,預設為false

spring.jta.enabled是否開啟JTA support,預設為: true

spring.jta.exception-analyzer設定指定的異常分析類

spring.jta.filter-log-status使用Bitronix Transaction Manager時,是否寫mandatory logs,開啟的話,可以節省磁碟空間,但是除錯會複雜寫,預設為false

spring.jta.force-batching-enabled使用Bitronix Transaction Manager時,是否批量寫磁碟,預設為true.

spring.jta.forced-write-enabled使用Bitronix Transaction Manager時,是否強制寫日誌到磁碟,預設為true

spring.jta.graceful-shutdown-interval當使用Bitronix Transaction Manager,指定shutdown時等待事務結束的時間,超過則中斷,預設為60

spring.jta.jndi-transaction-synchronization-registry-name當使用Bitronix Transaction Manager時,在JNDI下得事務同步registry,預設為: java:comp/TransactionSynchronizationRegistry

spring.jta.jndi-user-transaction-name指定在JNDI使用Bitronix Transaction Manager的名稱,預設:java:comp/UserTransaction

spring.jta.journal當使用Bitronix Transaction Manager,指定The journal是否disk還是null還是一個類的全限定名,預設disk

spring.jta.log-dirTransaction logs directory.

spring.jta.log-part1-filename指定The journal fragment檔案1的名字,預設: btm1.tlog

spring.jta.log-part2-filename指定The journal fragment檔案2的名字,預設: btm2.tlog

spring.jta.max-log-size-in-mb指定journal fragments大小的最大值. 預設: 2M

spring.jta.resource-configuration-filename指定Bitronix Transaction Manager配置檔名.

spring.jta.server-id指定Bitronix Transaction Manager例項的id.

spring.jta.skip-corrupted-logs是否忽略corrupted log files檔案,預設為false.

spring.jta.transaction-manager-id指定Transaction manager的唯一標識.

spring.jta.warn-about-zero-resource-transaction當使用Bitronix Transaction Manager時,是否對沒有使用指定資源的事務進行警告,預設為: true

(4)cache快取的相關配置
cache

spring.cache.cache-names指定要建立的快取的名稱,逗號分隔(若該快取實現支援的話)

spring.cache.ehcache.config指定初始化EhCache時使用的配置檔案的位置指定.

spring.cache.guava.spec指定建立快取要使用的spec,具體詳見CacheBuilderSpec.

spring.cache.hazelcast.config指定初始化Hazelcast時的配置檔案位置

spring.cache.infinispan.config指定初始化Infinispan時的配置檔案位置.

spring.cache.jcache.config指定jcache的配置檔案.

spring.cache.jcache.provider指定CachingProvider實現類的全限定名.

spring.cache.type指定快取型別

mongodb
spring.mongodb.embedded.features指定要開啟的特性,逗號分隔.

spring.mongodb.embedded.version指定要使用的版本,預設: 2.6.10

redis
spring.redis.database指定連線工廠使用的Database index,預設為: 0

spring.redis.host指定Redis server host,預設為: localhost

spring.redis.password指定Redis server的密碼

spring.redis.pool.max-active指定連線池最大的活躍連線數,-1表示無限,預設為8

spring.redis.pool.max-idle指定連線池最大的空閒連線數,-1表示無限,預設為8

spring.redis.pool.max-wait指定當連線池耗盡時,新獲取連線需要等待的最大時間,以毫秒單位,-1表示無限等待

spring.redis.pool.min-idle指定連線池中空閒連線的最小數量,預設為0

spring.redis.port指定redis服務端埠,預設: 6379

spring.redis.sentinel.master指定redis server的名稱

spring.redis.sentinel.nodes指定sentinel節點,逗號分隔,格式為host:port.

spring.redis.timeout指定連線超時時間,毫秒單位,預設為0

springdata
spring.data.elasticsearch.cluster-name指定es叢集名稱,預設: elasticsearch

spring.data.elasticsearch.cluster-nodes指定es的叢集,逗號分隔,不指定的話,則啟動client node.

spring.data.elasticsearch.properties指定要配置的es屬性.

spring.data.elasticsearch.repositories.enabled是否開啟es儲存,預設為: true

spring.data.jpa.repositories.enabled是否開啟JPA支援,預設為: true

spring.data.mongodb.authentication-database指定鑑權的資料庫名

spring.data.mongodb.database指定mongodb資料庫名

spring.data.mongodb.field-naming-strategy指定要使用的FieldNamingStrategy.

spring.data.mongodb.grid-fs-database指定GridFS database的名稱.

spring.data.mongodb.host指定Mongo server host.

spring.data.mongodb.password指定Mongo server的密碼.

spring.data.mongodb.port指定Mongo server port.

spring.data.mongodb.repositories.enabled是否開啟mongodb儲存,預設為true

spring.data.mongodb.uri指定Mongo database URI.預設:mongodb://localhost/test

spring.data.mongodb.username指定登陸mongodb的使用者名稱.

spring.data.rest.base-path指定暴露資源的基準路徑.

spring.data.rest.default-page-size指定每頁的大小,預設為: 20

spring.data.rest.limit-param-name指定limit的引數名,預設為: size

spring.data.rest.max-page-size指定最大的頁數,預設為1000

spring.data.rest.page-param-name指定分頁的引數名,預設為: page

spring.data.rest.return-body-on-create當建立完實體之後,是否返回body,預設為false

spring.data.rest.return-body-on-update在更新完實體後,是否返回body,預設為false

spring.data.rest.sort-param-name指定排序使用的key,預設為: sort

spring.data.solr.host
指定Solr host,如果有指定了zk的host的話,則忽略。預設為: http://127.0.0.1:8983/solr

spring.data.solr.repositories.enabled是否開啟Solr repositories,預設為: true

spring.data.solr.zk-host指定zk的地址,格式為HOST:PORT.

(5)MQ訊息中介軟體的相關配置
activemq

spring.activemq.broker-url指定ActiveMQ broker的URL,預設自動生成.

spring.activemq.in-memory是否是記憶體模式,預設為true.

spring.activemq.password指定broker的密碼.

spring.activemq.pooled是否建立PooledConnectionFactory,而非ConnectionFactory,預設false

spring.activemq.user指定broker的使用者.

artemis(HornetQ捐獻給apache後的版本)
spring.artemis.embedded.cluster-password指定叢集的密碼,預設是啟動時隨機生成.

spring.artemis.embedded.data-directory指定Journal檔案的目錄.如果不開始持久化則不必要指定.

spring.artemis.embedded.enabled是否開啟內嵌模式,預設true

spring.artemis.embedded.persistent是否開啟persistent store,預設false.

spring.artemis.embedded.queues指定啟動時建立的佇列,多個用逗號分隔,預設: []

spring.artemis.embedded.server-id指定Server ID. 預設是一個自增的數字,從0開始.

spring.artemis.embedded.topics指定啟動時建立的topic,多個的話逗號分隔,預設: []

spring.artemis.host指定Artemis broker 的host. 預設: localhost

spring.artemis.mode指定Artemis 的部署模式, 預設為auto-detected(也可以為native or embedded).

spring.artemis.port指定Artemis broker 的埠,預設為: 61616

rabbitmq
spring.rabbitmq.addresses指定client連線到的server的地址,多個以逗號分隔.

spring.rabbitmq.dynamic是否建立AmqpAdmin bean. 預設為: true)

spring.rabbitmq.host指定RabbitMQ host.預設為: localhost)

spring.rabbitmq.listener.acknowledge-mode指定Acknowledge的模式.

spring.rabbitmq.listener.auto-startup是否在啟動時就啟動mq,預設: true)

spring.rabbitmq.listener.concurrency指定最小的消費者數量.

spring.rabbitmq.listener.max-concurrency指定最大的消費者數量.

spring.rabbitmq.listener.prefetch指定一個請求能處理多少個訊息,如果有事務的話,必須大於等於transaction數量.

spring.rabbitmq.listener.transaction-size指定一個事務處理的訊息數量,最好是小於等於prefetch的數量.

spring.rabbitmq.password指定broker的密碼.

spring.rabbitmq.port指定RabbitMQ 的埠,預設: 5672)

spring.rabbitmq.requested-heartbeat指定心跳超時,0為不指定.

spring.rabbitmq.ssl.enabled是否開始SSL,預設: false)

spring.rabbitmq.ssl.key-store指定持有SSL certificate的key store的路徑

spring.rabbitmq.ssl.key-store-password指定訪問key store的密碼.

spring.rabbitmq.ssl.trust-store指定持有SSL certificates的Trust store.

spring.rabbitmq.ssl.trust-store-password指定訪問trust store的密碼.

spring.rabbitmq.username指定登陸broker的使用者名稱.

spring.rabbitmq.virtual-host指定連線到broker的Virtual host.

hornetq
spring.hornetq.embedded.cluster-password指定叢集的密碼,預設啟動時隨機生成.

spring.hornetq.embedded.data-directory指定Journal file 的目錄. 如果不開啟持久化則不必指定.

spring.hornetq.embedded.enabled是否開啟內嵌模式,預設:true

spring.hornetq.embedded.persistent是否開啟persistent store,預設: false

spring.hornetq.embedded.queues指定啟動是建立的queue,多個以逗號分隔,預設: []

spring.hornetq.embedded.server-id指定Server ID. 預設使用自增數字,從0開始.

spring.hornetq.embedded.topics指定啟動時建立的topic,多個以逗號分隔,預設: []

spring.hornetq.host指定HornetQ broker 的host,預設: localhost

spring.hornetq.mode指定HornetQ 的部署模式,預設是auto-detected,也可以指定native 或者 embedded.

spring.hornetq.port指定HornetQ broker 埠,預設: 5445

jms
spring.jms.jndi-name指定Connection factory JNDI 名稱.

spring.jms.listener.acknowledge-mode指定ack模式,預設自動ack.

spring.jms.listener.auto-startup是否啟動時自動啟動jms,預設為: true

spring.jms.listener.concurrency指定最小的併發消費者數量.

spring.jms.listener.max-concurrency指定最大的併發消費者數量.

spring.jms.pub-sub-domain是否使用預設的destination type來支援 publish/subscribe,預設: false

(6)security安全機制的相關配置
spring security是springboot支援的許可權控制系統。

security.basic.authorize-mode要使用許可權控制模式.

security.basic.enabled是否開啟基本的鑑權,預設為true

security.basic.path需要鑑權的path,多個的話以逗號分隔,預設為[/**]

security.basic.realmHTTP basic realm 的名字,預設為Spring

security.enable-csrf是否開啟cross-site request forgery校驗,預設為false.

security.filter-orderSecurity filter chain的order,預設為0

security.headers.cache是否開啟http頭部的cache控制,預設為false.

security.headers.content-type是否開啟X-Content-Type-Options頭部,預設為false.

security.headers.frame是否開啟X-Frame-Options頭部,預設為false.

security.headers.hsts指定HTTP Strict Transport Security (HSTS)模式(none, domain, all).

security.headers.xss是否開啟cross-site scripting (XSS) 保護,預設為false.

security.ignored指定不鑑權的路徑,多個的話以逗號分隔.

security.oauth2.client.access-token-uri指定獲取access token的URI.

security.oauth2.client.access-token-validity-seconds指定access token失效時長.

security.oauth2.client.additional-information.[key]設定要新增的額外資訊.

security.oauth2.client.authentication-scheme指定傳輸不記名令牌(bearer token)的方式(form, header, none,query),預設為header

security.oauth2.client.authorities指定授予客戶端的許可權.

security.oauth2.client.authorized-grant-types指定客戶端允許的grant types.

security.oauth2.client.auto-approve-scopes對客戶端自動授權的scope.

security.oauth2.client.client-authentication-scheme傳輸authentication credentials的方式(form, header, none, query),預設為header方式

security.oauth2.client.client-id指定OAuth2 client ID.

security.oauth2.client.client-secret指定OAuth2 client secret. 預設是一個隨機的secret.

security.oauth2.client.grant-type指定獲取資源的access token的授權型別.

security.oauth2.client.id指定應用的client ID.

security.oauth2.client.pre-established-redirect-uri服務端pre-established的跳轉URI.

security.oauth2.client.refresh-token-validity-seconds指定refresh token的有效期.

security.oauth2.client.registered-redirect-uri指定客戶端跳轉URI,多個以逗號分隔.

security.oauth2.client.resource-ids指定客戶端相關的資源id,多個以逗號分隔.

security.oauth2.client.scopeclient的scope

security.oauth2.client.token-name指定token的名稱

security.oauth2.client.use-current-uri是否優先使用請求中URI,再使用pre-established的跳轉URI. 預設為true

security.oauth2.client.user-authorization-uri使用者跳轉去獲取access token的URI.

security.oauth2.resource.id指定resource的唯一標識.

security.oauth2.resource.jwt.key-uriJWT token的URI. 當key為公鑰時,或者value不指定時指定.

security.oauth2.resource.jwt.key-valueJWT token驗證的value. 可以是對稱加密或者PEMencoded RSA公鑰. 可以使用URI作為value.

security.oauth2.resource.prefer-token-info是否使用token info,預設為true

security.oauth2.resource.service-id指定service ID,預設為resource.

security.oauth2.resource.token-info-uritoken解碼的URI.

security.oauth2.resource.token-type指定當使用userInfoUri時,傳送的token型別.

security.oauth2.resource.user-info-uri指定user info的URI

security.oauth2.sso.filter-order如果沒有顯示提供WebSecurityConfigurerAdapter時指定的Filter order.

security.oauth2.sso.login-path跳轉到SSO的登入路徑預設為/login.

security.require-ssl是否對所有請求開啟SSL,預設為false.

security.sessions指定Session的建立策略(always, never, if_required, stateless).

security.user.name指定預設的使用者名稱,預設為user.

security.user.password預設的使用者密碼.

security.user.role預設使用者的授權角色.

(7)資料庫遷移工具相關配置
SpringBoot支援了兩種資料庫遷移工具,一個是flyway,一個是liquibase。其本身也支援sql script,在初始化資料來源之後執行指定的指令碼。

flyway
flyway.baseline-description對執行遷移時基準版本的描述.

flyway.baseline-on-migrate當遷移時發現目標schema非空,而且帶有沒有元資料的表時,是否自動執行基準遷移,預設false.

flyway.baseline-version開始執行基準遷移時對現有的schema的版本打標籤,預設值為1.

flyway.check-location檢查遷移指令碼的位置是否存在,預設false.

flyway.clean-on-validation-error當發現校驗錯誤時是否自動呼叫clean,預設false.

flyway.enabled是否開啟flywary,預設true.

flyway.encoding設定遷移時的編碼,預設UTF-8.

flyway.ignore-failed-future-migration當讀取元資料表時是否忽略錯誤的遷移,預設false.

flyway.init-sqls當初始化好連線時要執行的SQL.

flyway.locations遷移指令碼的位置,預設db/migration.

flyway.out-of-order是否允許無序的遷移,預設false.

flyway.password目標資料庫的密碼.

flyway.placeholder-prefix設定每個placeholder的字首,預設${.

flyway.placeholder-replacementplaceholders是否要被替換,預設true.

flyway.placeholder-suffix設定每個placeholder的字尾,預設}.

flyway.placeholders.[placeholder name]設定placeholder的value

flyway.schemas設定需要flywary遷移的schema,大小寫敏感,預設為連線預設的schema.

flyway.sql-migration-prefix遷移檔案的字首,預設為V.

flyway.sql-migration-separator遷移指令碼的檔名分隔符,預設__

flyway.sql-migration-suffix遷移指令碼的字尾,預設為.sql

flyway.tableflyway使用的元資料表名,預設為schema_version

flyway.target遷移時使用的目標版本,預設為latest version

flyway.url遷移時使用的JDBC URL,如果沒有指定的話,將使用配置的主資料來源

flyway.user遷移資料庫的使用者名稱

flyway.validate-on-migrate遷移時是否校驗,預設為true.

liquibase
liquibase.change-logChange log 配置檔案的路徑,預設值為classpath:/db/changelog/db.changelog-master.yaml

liquibase.check-change-log-location是否堅持change log的位置是否存在,預設為true.

liquibase.contexts逗號分隔的執行時context列表.

liquibase.default-schema預設的schema.

liquibase.drop-first是否首先drop schema,預設為false

liquibase.enabled是否開啟liquibase,預設為true.

liquibase.password目標資料庫密碼

liquibase.url要遷移的JDBC URL,如果沒有指定的話,將使用配置的主資料來源.

liquibase.user目標資料使用者名稱

(8)其他常用配置屬性
aop

spring.aop.auto是否支援@EnableAspectJAutoProxy,預設為: true

spring.aop.proxy-target-classtrue為使用CGLIB代理,false為JDK代理,預設為false

application
spring.application.admin.enabled是否啟用admin特性,預設為: false

spring.application.admin.jmx-name指定admin MBean的名稱,預設為: org.springframework.boot:type=Admin,name=SpringApplication

autoconfig
spring.autoconfigure.exclude配置要排除的Auto-configuration classes.

batch
spring.batch.initializer.enabled是否在必要時建立batch表,預設為true

spring.batch.job.enabled是否在啟動時開啟batch job,預設為true

spring.batch.job.names指定啟動時要執行的job的名稱,逗號分隔,預設所有job都會被執行

spring.batch.schema指定要初始化的sql語句路徑,預設:classpath:org/springframework/batch/core/[email protected]@[email protected]@.sql)

spring.batch.table-prefix指定批量處理的表的字首.

jmx
spring.jmx.default-domain指定JMX domain name.

spring.jmx.enabled是否暴露jmx,預設為true

spring.jmx.server指定MBeanServer bean name. 預設為: mbeanServer)

mail
spring.mail.default-encoding指定預設MimeMessage的編碼,預設為: UTF-8

spring.mail.host指定SMTP server host.

spring.mail.jndi-name指定mail的jndi名稱

spring.mail.password指定SMTP server登陸密碼.

spring.mail.port指定SMTP server port.

spring.mail.properties指定JavaMail session屬性.

spring.mail.protocol指定SMTP server使用的協議,預設為: smtp

spring.mail.test-connection指定是否在啟動時測試郵件伺服器連線,預設為false

spring.mail.username指定SMTP server的使用者名稱.

sendgrid
spring.sendgrid.password指定SendGrid password.

spring.sendgrid.proxy.host指定SendGrid proxy host.

spring.sendgrid.proxy.port指定SendGrid proxy port.

spring.sendgrid.username指定SendGrid username.

social
spring.social.auto-connection-views是否開啟連線狀態的檢視,預設為false

spring.social.facebook.app-id指定應用id

spring.social.facebook.app-secret指定應用密碼

spring.social.linkedin.app-id指定應用id

spring.social.linkedin.app-secret指定應用密碼

spring.social.twitter.app-id指定應用ID.

spring.social.twitter.app-secret指定應用密碼

相關推薦

Spring Boot學習總結6.SpringBoot全域性配置檔案

上一篇我們總結了SpringBoot的核心註解以及一些簡單的配置,本篇我們來了解SpringBoot的全域性配置檔案。 Spring Boot專案使用一個全域性配置檔案application.properties或者是application.yml,在resource目錄下

Spring Boot學習總結14.Spring Boot整合Redis-與傳統方式對比

前面我們講解了如何使用Spring Boot來控制事務,下面我們來講解一下如何使用Spring Boot來整合Redis 為了對比傳統工程與Spring Boot整合的不同,以及彰顯Spring Boot整合的優勢,我們會逐一剖析傳統整合方式與Spring Boot整合方式。 一、傳統方式整

Spring Boot學習總結13.Spring Boot事務控制

上一篇我們講解了Spring Boot與MyBatis的結合開發,併成功操作了資料庫。眾所周知,保證資料庫一致性的操作,就是事務的控制。 而Spring事務管理可以分為兩種:程式設計式以及宣告式。 其中程式設計式事務就是使用編寫程式碼的方式,進行事務的控制。而宣告式事務一般通

spring boot 學習筆記 (6) 上傳檔案到 FastDFS

一、什麼是 FastDFS FastDFS 是一個開源的輕量級分散式檔案系統,它解決了大資料量儲存和負載均衡等問題,特別適合以中小檔案(建議範圍:4 KB < file_size < 500 MB)為載體的線上服務,如相簿網站、視訊網站等。在 UC 基於 FastDFS 開發向用戶提

Spring註解驅動開發使用@PropertySource載入配置檔案,我只看這一篇!!

## 寫在前面 > 很多小夥伴都在問:冰河,你的Spring專題更新完了嗎?怎麼感覺像是寫了一半啊?我:沒有更新完呀,整個專題預計會有70多篇。那怎麼更新了一半就去寫別的了呢?那是因為有很多其他的小夥伴在後臺留言說:急需學習一些其他的技術,所以,臨時調整的。放心,Spring專題會持續更新的!這不,今

Docker學習總結6.Docker守護式容器

上一篇總結,我們學習瞭如何執行一個“互動式”的容器,這些容器在命令互動之後就會停止。但是,在大多數情況下,我們需要一個能夠長期執行的容器來提供服務,這就是Docker的“守護式”程序。即我們可以使用守護方式來執行容器,使得容器可以在後臺一直保持執行狀態。 守護式程序的特點是:(1)能夠長期執

Spring boot學習事件啟動順序

ApplicationStartedEvent事件,所以在2.0版本中所有的事件按執行的先後順序如下: ApplicationStartingEvent ApplicationEnvironmentPreparedEvent ApplicationPreparedEve

Spring Boot學習總結(10)——SpringBoot打包成Docker映象

<build><!--定義jar檔名,可以自定義--><finalName>${project.name}-${project.version}</finalN

Spring Boot學習總結(7)——SpringBoot之於Spring優勢

一、Spring在Java EE開發中是實際意義上的標準,但我們在開發Spring的時候可能會遇到以下令人頭疼的問題:(1)大量配置檔案的定義;(2)與第三方軟體整合的技術問題,Spring每個新版本的

Spring Boot學習總結(8)——SpringBoot Common application properties(application.properties)詳解

# =================================================================== # COMMON SPRING BOOT PROPERTIES # # This sample file is provided as a guideline. Do N

面試Spring常見問題總結06

類名 truct htm 持久化框架 type 兩個 請求 method val 【常見面試問題總結文件夾>>>】 51、spring中的applicationContext.xml能不能改為其它名字 ContextLoaderListene

面試Spring常見問題總結07

之間 編程方式 順序 莫名其妙 接口編程 情況 spring容器 相互 lazy 【常見面試問題總結文件夾>>>】 61、Spring IoC容器的依賴有兩層含義: Bean依賴容器:也就是說Bean要依賴於容器,這裏的依賴是指容器負責創建B

Spring boot學習總結

高級 一個 命令行參數 內置 準備工作 exc 1.8 傳遞 開發 引言之前也沒有深入學習過spring框架,最近SpringBoot流行起來後想補下這方面的知識,於是照著SpringBoot官網上的英文教程開始helloworld入門,踩到幾個小坑,記錄下學習流程。 Sp

Spring Boot學習總結

請求 clas res control bject figure test 邏輯 context Spring Boot大大簡化了之前java項目的繁瑣xml配置,本文簡單的總結下spring boot的相關知識。 1,@RestController 配置在controll

Spring Boot學習總結

() 無配置文件 select 就會 配置文件 配置 模式 mysq pre 1,mybatis在spring boot下的2種使用模式 無配置文件註解版 application.properties添加相關配置 mybatis.type-aliases-package=c

[Spring Boot實戰系列] - No.6 Springboot PageHelper實現後臺分頁

Springboot PageHelper實現後臺分頁 PageHelper是一個很強大的分頁外掛,在Springboot的專案中,如果後臺突然需要改為分頁返回,甚至無需更改過多程式碼即可獲得分頁的結果。 1. 前期程式碼準備 建立一個springboot專案,配置資料庫以及

spring boot為例如何徹底實現前後端徹底分離

問題描述:為了實現前後端的徹底分離,我們徹底放棄使用.jsp的方式在前端顯示頁面中穿插java程式碼,但是帶來的問題也比較明顯,就是前端向後臺發出請求的時候可能會出現跨域的問題,瀏覽器為了安全會阻止跨域請求。 目前有一種很好的方法是使用node.js來解決這個問題,現在我提

Spring Boot 學習總結 (一)---入口類和@SpringBootApplication

入口類和@SpringBootApplication SpringBoot通常有一個名為*Application的入口類,入口類裡有一個main方法,這個main方法是一個標準的java應用的入口方法。在main方法中使用SpringApplication.run(*App

Spring Boot學習總結(14)——Spring Boot常見面試題彙總

1、什麼是 Spring Boot? Spring Boot 是 Spring 開源組織下的子專案,是 Spring 元件一站式解決方案,主要是簡化了使用 Spring 的難度,簡省了繁重的配置,提供了各種啟動器,開發者能快速上手。 2、為什麼要用 Spring Boot

Spring Boot學習總結(1)——Spring Boot入門

摘要:Spring Boots是為了幫助開發人員很容易的創建出獨立執行和產品級別的基於 Spring 框架的應用。 從 Spring Boot 專案名稱中的 Boot 可以看出來,Spring