Spring boot 第四章 全局配置

Spring Boot項目使用一個全局的配置文件application.properties或者是application.yml,在resources目錄html

下或者類路徑下的/config下,通常咱們放到resources下。react

一、修改tomcat的端口爲8088

輸入圖片說明

啓動後web

輸入圖片說明

從新啓動看效果redis

二、修改DispatcherServlet

Spring boot 2.x 由原來的server.servlet-path 改成server.servlet.pathspring

可是測試發現無效。不知道爲啥mongodb

三、spring boot properties

放個大招shell

spring boot docs數據庫

全局註解docs:spring boot properties編程

application配置文檔json

四、starter pom

spring boot 爲咱們提供了簡化企業級開發絕大數場景的starter pom, 只要使用了應用場景所須要的starter pom ,相關的技術配置將會消除,就能夠獲得Spring boot 爲咱們提供的自動配置的bean

spring boot 官方starter pom

spring-boot-starter	                           // springboot核心starter ,包括自動配置,日誌,yaml配置文件的支持
spring-boot-starter-activemq                 // Starter for JMS messaging using Apache ActiveMQ
spring-boot-starter-artemis                   // Starter for JMS messaging using Apache Artemis
spring-boot-starter-amqp	                   // 使用spring-rabbit支持AMQP
spring-boot-starter-aop	                   // 使用AOP和AspectJ支持面向切面編程

spring-boot-starter-remote-shell	           // 提供基於ssh協議的監控和管理

spring-boot-starter-batch	                   // 對springBatch支持
spring-boot-starter-cache	                   // 對SpringCache抽象的支持
spring-boot-starter-cloud-connectors	   // 對雲平臺(Cloud Foundry ,Heroku)提供的服務簡化的鏈接方式
spring-boot-starter-data-cassandra.      // Starter for using Cassandra distributed database and Spring Data Cassandra
spring-boot-starter-data-cassandra-reactive // Starter for using Cassandra distributed database and Spring Data Cassandra Reactive
spring-boot-starter-data-couchbase      // Starter for using Couchbase document-oriented database and Spring Data Couchbase
spring-boot-starter-data-couchbase-reactive  // Starter for using Couchbase document-oriented database and Spring Data Couchbase Reactive
spring-boot-starter-data-elasticsearch.   // 對spring-data-elasticsearch的支持

spring-boot-starter-data-jpa	            // 對jpa的支持,包括spring-data-jap,spring-orm,Hibernate
spring-boot-starter-data-ldap                // Starter for using Spring Data LDAP
spring-boot-starter-data-mongodb         // 經過spring-data-mongodb對mongodb的支持
spring-boot-starter-data-mongodb-reactive //Starter for using MongoDB document-oriented database and Spring Data MongoDB Reactive
spring-boot-starter-data-neo4j              // Starter for using Neo4j graph database and Spring Data Neo4j
spring-boot-starter-data-redis               // Starter for using Redis key-value data store with Spring Data Redis and the Lettuce client
spring-boot-starter-data-redis-reactive  // Starter for using Redis key-value data store with Spring Data Redis reactive and the Lettuce client
spring-boot-starter-data-rest	            // 經過spring-data-rest-webmvc對spring Data reposity暴露爲REST形式的服務
spring-boot-starter-data-solr	            // 經過spring-data-solr對Apache Solr的支持
spring-boot-starter-data-freemaker	    // 對Freemaker的支持
spring-boot-starter-data-groovy-templates	 // 對Groovy模版引擎的支持
spring-boot-starter-hateoas	            // 經過spring-hateoas對基於HATEOAS的REST形式的網絡服務的支持
spring-boot-starter-hornetq	            // 經過HornetQ對JMS的支持
spring-boot-starter-integration	            // 對系統集成框架spring-integration的支持
spring-boot-starter-jdbc	                    // 對JDBC數據庫的支持
spring-boot-starter-jersey	                    // 對Jersey REST形式的網絡服務的支持
spring-boot-starter-jooq                        // Starter for using jOOQ to access SQL databases. An alternative to spring-boot-starter-data-jpa or spring-boot-starter-jdbc
spring-boot-starter-json                        // Starter for reading and writing json
spring-boot-starter-jta-atomikos	    // 經過Atomikos對分佈式事物的支持
spring-boot-starter-jta-bitronix	            // 經過Bitronix對分佈式事物的支持
spring-boot-starter-jta-narayana            // Starter for JTA transactions using Narayana
spring-boot-starter-mail	                    // 對spring mail的支持
spring-boot-starter-mustache	            // 對Mustache模版引擎的支持
spring-boot-starter-security	            // 對spring-security的支持
spring-boot-starter-social-facebook	    // 經過spring-social-facebook 對facebook的支持
spring-boot-starter-social-twitter	    // 經過spring-social-twitter 對twitter的支持
spring-boot-starter-social-linkedin	    // 經過spring-social-linkedin 對linkedin的支持
spring-boot-starter-thymeleaf	            // 對Thymeleaf模版引擎的支持,包含於spring的整合配置
spring-boot-starter-velocity	            // 對velocity模版引擎的支持
spring-boot-starter-web	                    // 對web項目開發的支持,包含tomcat和spring-webmvc
spring-boot-starter-Tomcat	            // springboot默認容器tomcat
spring-boot-starter-Jetty	                    // jetty容器
spring-boot-starter-undertow	            // Undertow容器
spring-boot-starter-logging	            // 默認日誌輸出框架Logback
spring-boot-starter-log4j	                    // 支持log4j
spring-boot-starter-websocket	            // websocket的支持
spring-boot-starter-ws	                    // spring webservice的支持

五、spring boot xml 配置文件

Spring boot 提倡零配置,即無xml配置,可是實際項目中,可能有一些特殊要求,你必須使用xml配置,這時咱們能夠經過Spring 提供@ImportResource來家在xml配置,例如

@ImportResource({"classpath:some-context.xml","classpath:another-context.xml"})

六、spring boot 日誌

spring boot 對各類日誌框架作了支持,咱們能夠經過配置來修改默認的日誌配置:

logging.level.org.springframework=debug

格式:

loggin.level.* =

相關文章
相關標籤/搜索