Spring Boot經常使用註解:
@Service: 註解在類上,表示這是一個業務層bean
@Controller:註解在類上,表示這是一個控制層bean
@Repository: 註解在類上,表示這是一個數據訪問層bean
@Component: 註解在類上,表示通用bean ,value不寫默認就是類名首字母小寫
@Autowired:按類型注入.默認屬性required= true;當不能肯定 Spring 容器中必定擁有某個類的Bean 時, 能夠在須要自動注入該類 Bean 的地方可使用 @Autowired(required = false), 這等於告訴Spring:在找不到匹配Bean時也不拋出BeanCreationException 異常。@Autowired 和 @Qualifier 結合使用時,自動注入的策略就從 byType 轉變byName 了。@Autowired能夠對成員變量、方法以及構造函數進行註釋,而 @Qualifier 的標註對象是成員變量、方法入參、構造函數入參。正是因爲註釋對象的不一樣,因此 Spring 不將 @Autowired 和 @Qualifier 統一成一個註釋類。
@Resource: 按名稱裝配html
區別:java
@Resource默認按照名稱方式進行bean匹配,@Autowired默認按照類型方式進行bean匹配web
@Resource(importjavax.annotation.Resource;)是J2EE的註解,@Autowired(importorg.springframework.beans.factory.annotation.Autowired;)是Spring的註解
@Configuration:註解在類上,表示這是一個IOC容器,至關於spring的配置文件,java配置的方式。 IOC容器的配置類通常與 @Bean 註解配合使用,用 @Configuration 註解類等價與 XML 中配置 beans,用@Bean 註解方法等價於 XML 中配置 bean。
@Bean: 註解在方法上,聲明當前方法返回一個Beanspring
@Scope:註解在類上,描述spring容器如何建立Bean實例。sql
(1)singleton: 表示在spring容器中的單例,經過spring容器得到該bean時老是返回惟一的實例數據庫
(2)prototype:表示每次得到bean都會生成一個新的對象apache
(3)request:表示在一次http請求內有效(只適用於web應用)json
(4)session:表示在一個用戶會話內有效(只適用於web應用)緩存
(5)globalSession:表示在全局會話內有效(只適用於web應用)tomcat
在多數狀況,咱們只會使用singleton和prototype兩種scope,若是未指定scope屬性,默認爲singleton
@Value:註解在變量上,從配置文件中讀取。
例如:@Value(value = 「#{message}」)
@ConfigurationProperties 賦值,將註解轉換成對象。給對象賦值。車險項目:HttpClientSetting類
@Profile:註解在方法類上在不一樣狀況下選擇實例化不一樣的Bean特定環境下生效!!!!!!!!!!!!!!!!!
@SpringBootApplication:@SpringBootApplication=@ComponentScan+@Configuration+@EnableAutoConfiguration:約定優於配置
@EnableAutoConfiguration啓用 Spring 應用程序上下文的自動配置,試圖猜想和配置您可能須要的bean。自動配置類一般採用基於你的classpath 和已經定義的 beans 對象進行應用。被 @EnableAutoConfiguration 註解的類所在的包有特定的意義,而且做爲默認配置使用。一般推薦將 @EnableAutoConfiguration 配置在 root 包下,這樣全部的子包、類均可以被查找到。
@ComponentScan:註解在類上,掃描標註了@Controller等註解的類,註冊爲bean 。@ComponentScan 爲 @Configuration註解的類配置組件掃描指令。@ComponentScan 註解會自動掃描指定包下的所有標有 @Component註解的類,並註冊成bean,固然包括 @Component下的子註解@Service、@Repository、@Controller。
@RestController @RestController 是一個結合了 @ResponseBody 和 @Controller 的註解
@Responsebody 註解表示該方法的返回的結果直接寫入 HTTP 響應正文(ResponseBody)中,通常在異步獲取數據時使用,一般是在使用 @RequestMapping 後,返回值一般解析爲跳轉路徑,加上@Responsebody 後返回結果不會被解析爲跳轉路徑,而是直接寫入HTTP 響應正文中。
@RequestBody
@PathVariable
@RequestParam
二者的做用都是將request裏的參數的值綁定到contorl裏的方法參數裏的,區別在於,URL寫法不一樣。
當請求參數username不存在時會有異常發生,能夠經過設置屬性required=false解決,例如:
@RequestParam(value="username",required=false)
使用@RequestParam時,URL是這樣的:http://host:port/path?參數名=參數值
使用@PathVariable時,URL是這樣的:http://host:port/path/參數值
不寫的時候也能夠獲取到參數值,可是必須名稱對應。參數能夠省略不寫
@RequestMapping 和請求報文是作對應的
a:value,指定請求的地址
b:method 請求方法類型 這個不寫的話,自適應:get或者post
c:consumes 請求的提交內容類型
d:produces 指定返回的內容類型 僅當request請求頭中的(Accept)類型中包含該指定類型才返回
e: params 指定request中必須包含某些參數值
f:headers 指定request中必須包含指定的header值
g: name 指定映射的名稱
@RequestMapping(method = RequestMethod.GET)
@RequestMapping(method = RequestMethod.POST)
@RequestMapping(method = RequestMethod.PUT)
@RequestMapping(method = RequestMethod.DELETE)
固然也可使用
@GetMapping
@PostMapping
@PutMapping
@DeleteMapping 這與上面的是同樣的效果
@EnablCaching @EnableCaching註解是spring framework中的註解驅動的緩存管理功能。自spring版本3.1起加入了該註解。若是你使用了這個註解,那麼你就不須要在XML文件中配置cache manager了。
@suppresswarnings 抑制警告
@Modifying 若是是增,改,刪加上此註解
1:方法的返回值應該是int,表示更新語句所影響的行數。
2:在調用的地方必須加事務,沒有事務不能正常執行。@Transactional 事務註解
@Query 自定義查詢語句 JPQL
Spring Boot經常使用配置:
@SpringBootApplication開啓了Spring的組件掃描和Spring Boot的自動配置功能。實際上, @SpringBootApplication將三個有用的註解組合在了一塊兒。
@SpringBootApplication
所在類的同級目錄以及它的子目錄。本章稍後會寫一個簡單的Spring MVC控制器,使用@Controller進行註解,這樣組件掃描才能找到它。在Spring Boot的早期版本中,你須要在ReadingListApplication類上同時標上這三個註解,但從Spring Boot 1.2.0開始,有@SpringBootApplication就好了。
scope描述了spring容器如何新建bena的實例,spring的scope有如下幾種,經過@Scope註解來實現
另外,在spring batch中還有一個Scope是使用@StepScope,用在批處理中。
在咱們實際開發的時候,常常會遇到在bean使用以前或者以後作一些必要的操做,spring 對bean的生命週期的操做提供了支持。在使用java配置和註解配置下提供以下兩種方式:
spring EL-Spring表達式語言,支持在xml和註解中使用表達式,相似於jsp的EL表達式語言。
spring開發中常常涉及調用各類資源的狀況,包含普通文件,網址,配置文件,系統環境變量等,咱們可使用 spring表達式語言實現資源的注入。
spring主要在註解@Vavle的參數中使用表達式。
下面演示一下幾種狀況:
Profile爲在不一樣環境下使用不一樣的配置提供了支持(開發環境下的配置和生產環境下的配置不一樣,好比數據庫)
一、定義一個bean
public class CustomProfileBean { private String content; public CustomProfileBean(String content) { super(); this.content = content; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } }
二、配置
@Configuration public class CustomProfileConfig { @Bean @Profile("dev")//Profile爲dev時實例化devCustomProfileBean public CustomProfileBean devCustomProfileBean(){ return new CustomProfileBean("from development pfofile"); } @Bean @Profile("prod")//Profile爲prod時實例化prodCustomProfileBean public CustomProfileBean prodCustomProfileBean(){ return new CustomProfileBean("from production profile"); } }
三、啓動運行
public class CustomProfileMain { public static void main(String [] args){ //AnnotationConfigApplicationContext做爲spring容器,接受一個配置類做爲參數 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); //先將活動的Profile設置爲prod context.getEnvironment().setActiveProfiles("prod"); //後置註冊Bean配置類,否則會報bean未定義的錯誤 context.register(CustomProfileConfig.class); //刷新容器 context.refresh(); CustomProfileBean demoBean = context.getBean(CustomProfileBean.class); System.out.println(demoBean.getContent()); context.close(); } }
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true"><!-- debug="true"設置調試模式 --> <!--定義日誌文件的存儲地址 勿在 LogBack 的配置中使用相對路徑,文件要以logback-spring.xml命名--> <springProfile name="test"> <property name="catalina.base" value="/home/webapp/logs/spring-boot" /> </springProfile> <springProfile name="prod"> <property name="catalina.base" value="/app/webapp/logs/spring-boot" /> </springProfile> <springProfile name="dev"> <property name="catalina.base" value="H:/logs/spring-boot" /> </springProfile> <!--<springProperty scope="context" name="catalina.base" source="catalina.base"/>--> <!-- 日誌地址 --> <!--<property name="catalina.base" value="H:/logs"></property>--> <!-- 控制檯輸出 --> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} 耗時:%r 日誌來自:%logger{50} 日誌類型: %-5p 日誌內容:%m%n</pattern> </encoder> </appender> <!-- 按照天天生成日誌文件 --> <appender name="DEFAULT-APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${catalina.base}/logs/common-default.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!--日誌文件輸出的文件名 --> <FileNamePattern>${catalina.base}/logs/common-default-%d{yyyy-MM-dd}.log</FileNamePattern> <!--日誌文件保留天數 --> <MaxHistory>30</MaxHistory> </rollingPolicy> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <!--格式化輸出:%d表示日期,%thread表示線程名,%-5level:級別從左顯示5個字符寬度%msg:日誌消息,%n是換行符 --> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> </encoder> <!--日誌文件最大的大小 --> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>10MB</MaxFileSize> </triggeringPolicy> </appender> <!-- 按照天天生成日誌文件 --> <appender name="INFO-APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${catalina.base}/logs/info-log.log</File> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!--日誌文件輸出的文件名 --> <FileNamePattern>${catalina.base}/logs/info-log-%d{yyyy-MM-dd}.log</FileNamePattern> <!--日誌文件保留天數 --> <MaxHistory>30</MaxHistory> </rollingPolicy> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <!-- 格式化輸出:%d表示日期,%thread表示線程名,%-5level:級別從左顯示5個字符寬度%msg:日誌消息,%n是換行符 --> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> </encoder> <!--日誌文件最大的大小 --> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <MaxFileSize>10MB</MaxFileSize> </triggeringPolicy> </appender> <logger name="com.google.code.yanf4j" level="ERROR" /> <!-- show parameters for hibernate sql 專爲 Hibernate 定製 --> <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" /> <logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" /> <logger name="org.hibernate.SQL" level="DEBUG" /> <logger name="org.hibernate.engine.QueryParameters" level="DEBUG" /> <logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" /> <!--myibatis log configure--> <logger name="org.apache.ibatis" level="DEBUG"/> <logger name="java.sql.Connection" level="DEBUG"/> <logger name="java.sql.Statement" level="DEBUG"/> <logger name="java.sql.PreparedStatement" level="DEBUG"/> <logger name="net.rubyeye.xmemcached" level="INFO"/> <logger name="org.springframework" level="INFO"/> <logger name="net.sf.ehcache" level="INFO"/> <logger name="org.apache.zookeeper" level="INFO" /> <!-- 指定某一個包或者某一個類的打印級別以及是否傳入root進行打印 --> <!-- addtivity:是否向上級loger傳遞打印信息。默認是true。--> <!-- <loger>能夠包含零個或多個<appender-ref>元素,標識這個appender將會添加到這個loger。--> <!-- name:用來指定受此loger約束的某一個包或者具體的某一個類。--> <!-- level: 用來設置打印級別,大小寫無關:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,還有一個特俗值INHERITED或者同義詞NULL,表明強制執行上級的級別。 若是未設置此屬性,那麼當前loger將會繼承上級的級別。--> <!-- 爲全部開頭爲dao的類打印sql語句 --> <!-- <logger name="dao" level="DEBUG"> <appender-ref ref="INFO-APPENDER" /> </logger> --> <logger name="com.only.mate" level="DEBUG" additivity="true"> <appender-ref ref="INFO-APPENDER" /> </logger> <!-- 也是<loger>元素,可是它是根loger。只有一個level屬性,應爲已經被命名爲"root". --> <root level="DEBUG"> <appender-ref ref="STDOUT"/> <appender-ref ref="DEFAULT-APPENDER"/> </root> </configuration>
建立一個服務,實現ApplicationContextAware接口
import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Service; @Service public class CustomProfileService implements ApplicationContextAware{ private ApplicationContext applicationContext = null; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } public void doSomething() { //獲取當前系統環境 String[] springActives = applicationContext.getEnvironment().getActiveProfiles(); String springActive = ""; if(springActives.length > 0) { springActive = springActives[0]; }else { springActive = applicationContext.getEnvironment().getDefaultProfiles()[0]; } System.out.println("當前的開發環境:"+ springActive); } }
配置類
@Configuration @ComponentScan(basePackages="com.only.mate.springboot.basic.profile") public class CustomProfileConfig { @Bean @Profile("dev")//Profile爲dev時實例化devCustomProfileBean public CustomProfileBean devCustomProfileBean(){ return new CustomProfileBean("from development pfofile"); } @Bean @Profile("prod")//Profile爲prod時實例化prodCustomProfileBean public CustomProfileBean prodCustomProfileBean(){ return new CustomProfileBean("from production profile"); } }
啓動類
public class CustomProfileMain { public static void main(String [] args){ //AnnotationConfigApplicationContext做爲spring容器,接受一個配置類做爲參數 AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); //先將活動的Profile設置爲prod context.getEnvironment().setActiveProfiles("prod"); //後置註冊Bean配置類,否則會報bean未定義的錯誤 context.register(CustomProfileConfig.class); //刷新容器 context.refresh(); CustomProfileBean customProfileBean = context.getBean(CustomProfileBean.class); System.out.println(customProfileBean.getContent()); CustomProfileService customProfileService = context.getBean(CustomProfileService.class); customProfileService.doSomething(); context.close(); } }
Spring Boot經常使用配置參數(application.properties)
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視圖的後綴.
spring.messages.basename
指定message的basename,多個以逗號分隔,若是不加包名的話,默認從classpath路徑開始,默認: messages
spring.messages.cache-seconds
設定加載的資源文件緩存失效時間,-1的話爲永不過時,默認爲-1
spring.messages.encoding
設定Message bundles的編碼,默認: UTF-8
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
spring.view.prefix
設定mvc視圖的前綴.
spring.view.suffix
設定mvc視圖的後綴.
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.enabled
是否開啓文件上傳支持,默認爲true
multipart.file-size-threshold
設定文件寫入磁盤的閾值,單位爲MB或KB,默認爲0
multipart.location
指定文件上傳路徑.
multipart.max-file-size
指定文件大小最大值,默認1MB
multipart.max-request-size
指定每次請求的最大值,默認爲10MB
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
指定使用模板的視圖列表.
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
設定須要解析的視圖名稱.
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
指定使用模板的視圖名,多個以逗號分隔.
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
指定要使用模板的視圖名.
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
指定要使用模板的視圖名稱.
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
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.
spring.jersey.filter.order
指定Jersey filter的order,默認爲: 0
spring.jersey.init
指定傳遞給Jersey的初始化參數.
spring.jersey.type指定Jersey的集成類型,能夠是servlet或者filter.