• 配置文件application.properties参数详解


    springboot提供了许多启动器starter,大部分的启动器都有配置属性,这些配置属性一般可以在这里找到:

    xxxxxxxx-autoconfigure-xxxxx.jar/META-INF/spring-configuration-metadata.json

    application.properties

    # 这些属性是否生效取决于对应的组件是否声明为 Spring 应用程序上下文里的 Bean(基本是自动配置的),
    # 为一个不生效的组件设置属性是没有用的。
    
    ################ 文件上传 ################
    # 开启上传支持, 默认是true
    spring.servlet.multipart.enabled=true
    # 最大文件大小, 单位MB, 默认是1MB
    spring.servlet.multipart.max-file-size=1MB
    # 最大请求大小, 单位MB, 默认是10MB
    spring.servlet.multipart.max-request-size=10MB
    # 文件上传位置
    spring.servlet.multipart.location=/upload
    # 大于该值的文件会被写到磁盘上, 单位B, 默认是0B
    spring.servlet.multipart.file-size-threshold=0B
    
    ################ 服务器配置 ################
    # 服务器地址
    server.address=127.0.0.1
    # 端口号, 默认是8080
    server.port=8080
    # 应用上下文路径
    server.servlet.context-path=/appContext
    # servlet 上下文参数
    # server.servlet.context-parameters.[param name] = [param value]
    server.servlet.context-parameters.email = lin@m
    
    ################ mvc配置 ################
    # 异步请求处理超时前的等待时间(单位为毫秒)。
    # 如果没有设置该属性,则使用底层实现 的默认超时时间,
    # 比如,Tomcat 上使用 Servlet 3 时超时时间为 10 秒
    spring.mvc.async.request-timeout=
    # 要使用的日期格式
    spring.mvc.date-format=dd/MM/yyyy
    # 开启 favicon.ico 的解析
    spring.mvc.favicon.enabled=true
    # 在重定向的场景下,是否要忽略“默认”模型对象的内容, 默认是true
    spring.mvc.ignore-default-model-on-redirect=true
    # 要使用的地域配置
    spring.mvc.locale=zh_CN
    # 消息代码格式
    spring.mvc.message-codes-resolver-format=prefix_error_code
    # Spring MVC 视图前缀
    spring.mvc.view.prefix=
    # Spring MVC 视图后缀
    spring.mvc.view.suffix=
    
    ################ jsp-servlet配置 ################
    # 针对 jsp 使用的 Servlet 类名, 默认是 org.apache.jasper.servlet.JspServlet
    # 需要tomcat-embed-jasper依赖
    server.servlet.jsp.class-name=org.apache.jasper.servlet.JspServlet
    # JspServlet 是否要注册到内嵌的 Servlet 容器里, 默认是true
    server.servlet.jsp.registered=true
    # Jsp Servlet 初始化参数
    # server.servlet.jsp.init-parameters.[param name] = [param value]
    server.servlet.jsp.init-parameters.userName = myName
    
    ################ Session配置 ################
    # 会话 Cookie 的域
    server.servlet.session.cookie.domain=www.lin.com
    # Cookie 注释
    server.servlet.session.cookie.comment=购物信息
    # Cookie 最大保存时间, 单位s
    server.servlet.session.cookie.max-age=10s
    # Cookie 名称
    server.servlet.session.cookie.name=carts
    # Cookie 的访问路径
    server.servlet.session.cookie.path=/page/
    # Cookie安全性设置, true表示cookie无法通过document.cookie读取到cookie信息,这样能有效的防止XSS攻击
    server.servlet.session.cookie.http-only=true
    # Cookie安全性设置, true表示cookie只能用https协议发送给服务器,用http协议是不发送的
    server.servlet.session.cookie.secure=true
    # Session过期时间, 默认是30分钟
    server.servlet.session.timeout=30m
    # Session是否持久化, 默认是false
    server.servlet.session.persistent=false
    # 本地的session数据存放地址
    server.servlet.session.store-dir=
    # Session的追踪模式
    # SessionTrackingMode下有三种可选值:COOKIE, URL, SSL
    server.servlet.session.tracking-modes = COOKIE, URL
    
    ################ Tomcat配置 ################
    # 创建日志文件的目录, 默认是logs
    server.tomcat.accesslog.directory=logs
    # 是否开启访问日志, 默认是false
    server.tomcat.accesslog.enabled=false
    # 访问日志的格式, 默认是common
    server.tomcat.accesslog.pattern=common
    # 日志名前缀, 默认是access_log
    server.tomcat.accesslog.prefix=access_log
    # 日志后缀名, 默认是.log
    server.tomcat.accesslog.suffix=.log
    # 用来解码 URI 的字符编码, 默认是UTF-8
    server.tomcat.uri-encoding=UTF-8
    # 最小备用线程数,tomcat启动时的初始化的线程数。
    server.tomcat.min-spare-threads=10
    # tomcat可创建的最大的线程数,每一个线程处理一个请求,超过这个请求数后,
    # 客户端请求只能排队,等有线程释放才能处理。
    server.tomcat.max-threads=200
    # 最长等待时间,如果没有数据进来,等待一段时间后断开连接,释放线程。
    server.tomcat.connection-timeout=5000
    
    ################ Cache配置 ################
    # 如果底层缓存管理器支持缓存名的话,可以在这里指定要创建的缓存名列表,用逗号分隔。
    # 通常这会禁用运行时创建其他额外缓存的能力。
    spring.cache.cache-names=
    # 用来初始化 EhCache 的配置文件位置
    spring.cache.ehcache.config=classpath:ehcache.xml
    # 缓存类型,默认根据环境自动检测
    spring.cache.type=ehcache
    
    ################ data配置 ################
    # 开启 JPA 仓库, 默认是true
    spring.data.jpa.repositories.enabled=true
    
    ###=== spring.data.mongodb ===###
    # 身份认证数据库名
    spring.data.mongodb.authentication-database=
    # 数据库名
    spring.data.mongodb.database=
    # 要使用的 FieldNamingStrategy 的全限定名
    spring.data.mongodb.field-naming-strategy=org.springframework.data.mapping.model.CamelCaseAbbreviatingFieldNamingStrategy
    # GridFS 数据库名称
    spring.data.mongodb.grid-fs-database=
    # MongoDB 服务器地址
    spring.data.mongodb.host=
    # 端口号
    spring.data.mongodb.port=
    # MongoDB 账号
    spring.data.mongodb.username=
    # MongoDB 密码
    spring.data.mongodb.password=
    spring.data.mongodb.repositories.type=auto
    # Mongo 数据库 URI。设置了该属性后就主机和端口号会被忽略。
    # (默认值: mongodb:// localhost/test)
    spring.data.mongodb.uri=mongodb://localhost/test
    
    ###=== spring.data.rest ===###
    # 用于发布仓库资源的基本路径
    spring.data.rest.base-path=
    # 分页数据的默认页大小
    spring.data.rest.default-page-size=
    # 最大分页大小
    spring.data.rest.max-page-size=
    # 用于标识一次返回多少记录的 URL 查询字符串参数名。默认值:size
    spring.data.rest.limit-param-name=
    # URL 查询字符串参数的名称,用来标识返回哪一页。默认值:page
    spring.data.rest.page-param-name=
    # 在创建实体后是否返回一个响应体
    spring.data.rest.return-body-on-create=
    # 在更新实体后是否返回一个响应体
    spring.data.rest.return-body-on-update=
    # URL 查询字符串参数的名称,用来表示结果排序的方向。
    spring.data.rest.sort-param-name=
    
    ###=== spring.data.solr ===###
    # Solr 的主机地址。如果设置了 zk-host 则忽略该属性。
    spring.data.solr.host=http://127.0.0.1:8983/solr
    # 开启 solr 仓库, 默认是true
    spring.data.solr.repositories.enabled=true
    # 主机地址, 格式为HOST:PORT
    spring.data.solr.zk-host=
    
    ################ DataSource配置 ################
    # 数据库的 JDBC URL
    spring.datasource.url=
    # 数据库的登录密码
    spring.datasource.password=
    # 数据库的登录用户名
    spring.datasource.username=
    # JDBC 驱动的全限定类名。默认根据 URL 自动检测
    spring.datasource.driver-class-name=com.mysql.jdbc.Driver
    # 数据源名称
    spring.datasource.name=
    # DML的SQL文件位置
    spring.datasource.data=classpath:all.sql
    # 执行DML操作的用户名
    spring.datasource.data-username=
    # 执行DML操作的密码
    spring.datasource.data-password=
    # 数据源类型
    spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
    # 初始化数据库时发生错误是否终止
    spring.datasource.continue-on-error=true
    # 是否随机生成数据源名称
    spring.datasource.generate-unique-name=true
    # Schema(数据定义语言,Data Definition Language,DDL)脚本资源的引用。
    spring.datasource.schema=classpath:create.sql
    # SQL 初始化脚本里的语句分割符。默认是;
    spring.datasource.separator=;
    # 执行DDL操作的用户名
    spring.datasource.schema-username=
    # 执行DDL操作的密码
    spring.datasource.schema-password=
    # SQL 脚本的编码
    spring.datasource.sql-script-encoding=UTF-8
    # Platform to use in the DDL or DML scripts
    # (such as schema-${platform}.sql or data-${platform}.sql)
    spring.datasource.platform=all
    # JNDI location of the datasource. Class, url, username & password are ignored when set
    spring.datasource.jndi-name=
    # Whether to enable JMX support (if provided by the underlying pool)
    # 默认是false
    spring.datasource.jmx-enabled=false
    
    ###=== hikari datasource配置 ===###
    # 指定必须保持连接的最小值
    spring.datasource.hikari.minimum-idle=
    # 数据库密码
    spring.datasource.hikari.password=
    # 数据库用户名
    spring.datasource.hikari.username=
    # 指定连接池名字
    spring.datasource.hikari.pool-name=
    # 更新操作是否自动提交
    spring.datasource.hikari.auto-commit=true
    # 指定数据源的全限定名
    spring.datasource.hikari.data-source-class-name=
    # 指定driver的类名,默认从jdbc url中自动探测
    spring.datasource.hikari.driver-class-name=
    # 指定JDBC URL
    spring.datasource.hikari.jdbc-url=
    # 连接池中的连接能保持闲置状态的最长时间,单位为毫秒
    spring.datasource.hikari.idle-timeout=
    # 指定连接的超时时间,毫秒单位
    spring.datasource.hikari.connection-timeout=
    # 指定连接池最大的连接数,包括使用中的和空闲的连接
    spring.datasource.hikari.maximum-pool-size=
    # 使用Hikari connection pool时,多少毫秒检测一次连接泄露
    spring.datasource.hikari.leak-detection-threshold=
    # 指定校验连接合法性执行的sql语句
    spring.datasource.hikari.connection-test-query=
    # 连接的默认事务隔离级别
    spring.datasource.hikari.transaction-isolation=
    # 在连接验证失败前等待的超时时间,单位为秒
    spring.datasource.hikari.validation-timeout=
    # 是否允许池暂停(pool suspension)。在开启池暂停后会有性能会受到一定影响,
    # 除非你真的需要这个功能(例如在冗余的系统下),否则不要开启它。
    spring.datasource.hikari.allow-pool-suspension=true
    # 默认的 Catalog 名称
    spring.datasource.hikari.catalog=
    # 在所有新连接创建时都会执行的 SQL 语句,该语句会在连接加入连接池前执行
    spring.datasource.hikari.connection-init-sql=
    # 指定jndi的地址
    spring.datasource.hikari.data-source-j-n-d-i=
    # 使用Hikari connection pool时,指定要设置的属性
    # spring.datasource.hikari.data-source-properties.[key]
    spring.datasource.hikari.data-source-properties.keyp=aaa
    # 使用Hikari connection pool时,在心跳检查时传递的属性
    # spring.datasource.hikari.health-check-properties.[key]
    spring.datasource.hikari.health-check-properties.loopv=123
    spring.datasource.hikari.health-check-registry=
    # 初始化失败的超时时间
    spring.datasource.hikari.initialization-fail-timeout=
    # 指定内部查询是否要被隔离
    spring.datasource.hikari.isolate-internal-queries=true
    # 指定连接数据库的超时时间
    spring.datasource.hikari.login-timeout=
    # 指定连接池中连接的最大生存时间,毫秒单位
    spring.datasource.hikari.max-lifetime=
    spring.datasource.hikari.metric-registry=
    spring.datasource.hikari.metrics-tracker-factory=
    # 当使用Hikari connection pool时,是否标记数据源只读
    spring.datasource.hikari.read-only=
    # 指定Hikari connection pool是否注册JMX MBeans
    spring.datasource.hikari.register-mbeans=
    spring.datasource.hikari.scheduled-executor=
    spring.datasource.hikari.schema=
    
    ################ FreeMarker配置 ################
    # HttpServletRequest 的属性是否允许覆盖(隐藏)控制器生成的同名模型属性
    spring.freemarker.allow-request-override=
    # HttpSession 的属性是否允许覆盖(隐藏)控制器生成的同名模型属性
    spring.freemarker.allow-session-override=
    # 开启模板缓存
    spring.freemarker.cache=false
    # 模板编码, 默认是UTF-8
    spring.freemarker.charset=UTF-8
    # 检查模板位置是否存在
    spring.freemarker.check-template-location=true
    # 开启 FreeMarker 的 MVC 视图解析
    spring.freemarker.enabled=true
    
    ################ H2配置 ################
    # 开启控制台
    spring.h2.console.enabled=true
    # 可以找到控制台的路径
    spring.h2.console.path=/h2-console
    spring.h2.console.settings.trace=true
    spring.h2.console.settings.web-allow-others=true
    
    ################ Http配置 ################
    # HTTP 消息转换时优先使用 JSON 映射器
    spring.http.converters.preferred-json-mapper=jackson
    # HTTP 请求和响应的字符集。如果没有显式地指定 Content-Type 头,则将该属性值作为 这个头的值
    spring.http.encoding.charset=UTF-8
    # 开启 HTTP 编码支持, 默认是true
    spring.http.encoding.enabled=true
    # 强制将 HTTP 请求和响应编码为所配置的字符集, 默认是true
    spring.http.encoding.force=true
    
    ################ Jackson配置 ################
    # 日期格式字符串或日期格式类的全限定类名
    spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
    # 在序列化时控制属性是否也进行序列化
    spring.jackson.default-property-inclusion=non_empty
    # 是否开启Jackson的反序列化
    # spring.jackson.deserialization.[key]=
    spring.jackson.deserialization.accept-float-as-int=true
    # 是否开启json的generators
    # spring.jackson.generator.[key]=
    spring.jackson.generator.auto-close-json-content=true
    # 指定Joda date/time的格式,比如yyyy-MM-ddHH:mm:ss. 如果没有配置的话,dateformat会作为backup
    spring.jackson.joda-date-time-format=
    # 指定json使用的Local(语言)
    spring.jackson.locale=zh_CN
    # 是否开启Jackson通用的特性
    # spring.jackson.mapper.[key]=
    spring.jackson.mapper.accept-case-insensitive-enums=true
    # 是否开启jackson的parser特性
    # spring.jackson.parser.[key]=
    spring.jackson.parser.allow-backslash-escaping-any-character=true
    # 指定PropertyNamingStrategy(CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)
    # 或者指定PropertyNamingStrategy子类的全限定类名
    spring.jackson.property-naming-strategy=LOWER_CAMEL_CASE
    # 是否开启jackson的序列化
    # spring.jackson.serialization.[key]=
    spring.jackson.serialization.fail-on-empty-beans=true
    # 指定日期格式化时区,比如America/Los_Angeles或者GMT+10
    spring.jackson.time-zone=
    
    ################ Jpa配置 ################
    # 要操作的目标数据库,默认自动检测
    spring.jpa.database=mysql
    spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
    # 启动时是否要初始化 Schema
    spring.jpa.generate-ddl=true
    # hibernate. hbm2ddl.auto 属性的一个快捷方式。
    # 在使用嵌入式数据库时,默认为 create-drop , 其他情况下默认为 none 。
    spring.jpa.hibernate.ddl-auto=update
    # 命名策略的全限定类名
    spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
    # 注册 OpenEntityManagerInViewInterceptor, 在请求的整个处理过程中,
    # 将一个 JPA EntityManager 绑定到线程上。
    spring.jpa.open-in-view=true
    spring.jpa.mapping-resources=
    # JPA 提供方要设置的额外原生属性
    # spring.jpa.properties.[key]
    # 打开 SQL 语句日志
    spring.jpa.show-sql=true
    spring.jpa.hibernate.use-new-id-generator-mappings=true
    ################ mail配置 ################
    
    # 默认的 MimeMessage 编码
    spring.mail.default-encoding=UTF-8
    # SMTP 服务器主机地址
    spring.mail.host=
    # SMTP 服务器的登录密码
    spring.mail.password=
    # SMTP 服务器的登录用户名
    spring.mail.username=
    # SMTP 服务器的端口号
    spring.mail.port=
    # 附加的 JavaMail 会话属性
    # spring.mail.properties.[key]
    # SMTP 服务器用到的协议, 默认是smtp
    spring.mail.protocol=smtp
    # 在启动时测试邮件服务器是否可用
    spring.mail.test-connection=true

    这里对server.tomcat进行解释:

    • 前缀为server的配置项,对应的配置类为org.springframework.boot.autoconfigure.web.ServerProperties,ServerProperties类中有一个内部类Tomcat,对应前缀为server.tomcat的配置项。
    • 项目启动时,这些配置会被set到org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory类中(引入spring-boot-starter-web依赖,会自动引入spring-boot-starter-tomcat,就是说tomcat是系统默认的容器,所以会自动初始化),之后TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer()创建并启动Tomcat容器实例。
    • Tomcat内部使用的是java.util.concurrent.ThreadPoolExecutor线程池,容器启动时会在org.apache.tomcat.util.net.AbstractEndpoint.createExecutor()这里创建线程池,所以其中最大最小线程数、线程创建、销毁和分配的策略其实都是ThreadPoolExecutor的特性。
  • 相关阅读:
    1442. Count Triplets That Can Form Two Arrays of Equal XOR
    1441. Build an Array With Stack Operations
    312. Burst Balloons
    367. Valid Perfect Square
    307. Range Sum Query
    1232. Check If It Is a Straight Line
    993. Cousins in Binary Tree
    1436. Destination City
    476. Number Complement
    383. Ransom Note
  • 原文地址:https://www.cnblogs.com/myitnews/p/11878705.html
Copyright © 2020-2023  润新知