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: 按名称装配
区别:
@resource默认按照名称方式进行bean匹配,@autowired默认按照类型方式进行bean匹配
@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: 注解在方法上,声明当前方法返回一个bean
@scope:注解在类上,描述spring容器如何创建bean实例。
(1)singleton: 表示在spring容器中的单例,通过spring容器获得该bean时总是返回唯一的实例
(2)prototype:表示每次获得bean都会生成一个新的对象
(3)request:表示在一次http请求内有效(只适用于web应用)
(4)session:表示在一个用户会话内有效(只适用于web应用)
(5)globalsession:表示在全局会话内有效(只适用于web应用)
在多数情况,我们只会使用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为在不同环境下使用不同的配置提供了支持(开发环境下的配置和生产环境下的配置不同,比如数据库)
1、定义一个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; } }
2、配置
@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"); } }
3、启动运行
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.
如对本文有疑问, 点击进行留言回复!!
ScrollView和RecyclerView的滑动事件处理
配置JAVA环境+安装Android Studio全过程+踩坑记录
Android P Camera2当SD卡被拔出来自动切换到内部存储
android 多个edittext 判空监听 让Button动态是否可点击
Android开源项目滚轮选择器WheelPicker的基本用法总结
网友评论