Spring-Boot常见的应用属性配置集

深入原理之前先用好,用好之前先全面了解功能。

全面了解功能可以从官方文档的配置参数选项作为切入点。

Appendix A. Common application properties - Spring


# ===================================================================
# COMMON SPRING BOOT PROPERTIES
# 常见的Spring Boot属性集
#
# This sample file is provided as a guideline. Do NOT copy it in its
# entirety to your own application.               ^^^
# 提供配置样本文件作为指导(缺省值配置)。请勿将其全部复制到您自己的应用程序中。
# ===================================================================


# ----------------------------------------
# CORE PROPERTIES
# 核心属性集
# ----------------------------------------

# BANNER - 系统品牌的横幅广告
#banner:
  # Banner file encoding. 横幅文件的编码
#  charset: UTF-8
  # Banner file location. 横幅文件的位置
#  location: classpath:banner.txt

# LOGGING
logging:
  # Location of the logging configuration file. 日志记录配置文件的位置
#  config:
  # Log file name. 日志文件名
#  file:
  # Log levels severity mapping. 日志级别严重性映射
  level: info
  # Location of the log file. 日志文件的位置
#  path:

spring:
  # AOP
  aop:
    # Add @EnableAspectJAutoProxy.
#    auto: true
    # Whether subclass-based (CGLIB) proxies are to be created (true) as opposed to standard Java interface-based proxies (false). Defaults to "true" when using Spring Transaction Management, otherwise "false".
    # 代理目标类,基于子类的代理(CGLIB),基于接口的代理(Java)
    proxy-target-class: true
    # IDENTITY (ContextIdApplicationContextInitializer)
#  application:
    # Application index. 应用程序的索引
#      index:
    # Application name. 应用程序的名称
#      name:
      # ADMIN (SpringApplicationAdminJmxAutoConfiguration)
#      admin:
        # Enable admin features for the application.
        # 为应用程序启用管理员功能
#        enabled: false
        # JMX name of the application admin MBean.
        # 应用程序管理员MBean的JMX名称
#        jmx-name: org.springframework.boot:type=Admin,name=SpringApplication
  # AUTO-CONFIGURATION
#  autoconfigure:
    # Auto-configuration classes to exclude. 排除的自动配置类列表
#    exclude:
  # SPRING CACHE (CacheProperties)
#  cache:
    # Comma-separated list of cache names to create if supported by the underlying cache manager.
#    cache-names:
    # Cache type, auto-detected according to the environment by default. 缓存类型,默认情况下根据环境自动检测
#    type:
  # SPRING CONFIG - using environment property only (ConfigFileApplicationListener)
#  config:
    # Config file locations. 配置文件位置列表
#    location:
    # Config file name. 配置文件名
#    name: application
  # JMX
#  jmx:
    # JMX domain name. JMX的域名
#    default-domain:
    # Expose management beans to the JMX domain. 暴露管理beans到JMX域
#    enabled: true
  # MBeanServer bean name. 管理bean服务器的bean名称
#    server: mbeanServer
  # APPLICATION SETTINGS (SpringApplication)
  main:
    # Mode used to display the banner when the application runs.
    # 应用程序运行时用于显示横幅的模式
    banner-mode: log
    # Sources (class name, package name or XML resource location) to include in the ApplicationContext.
    # 包含在应用上下文中的bean资源对象集(类名,包名或XML资源位置)
#    sources:
  # FILE ENCODING (FileEncodingApplicationListener)
  # Expected character encoding the application must use.
  # 应用程序必须使用的预期的字符编码
  mandatory-file-encoding: UTF-8
  # PID FILE (ApplicationPidFileWriter)
#  pid:
    # Fail if ApplicationPidFileWriter is used but it cannot write the PID file.
    # 如果使用ApplicationPidFileWriter但无法写入PID文件,则失败
#    fail-on-write-error:
    # Location of the PID file to write (if ApplicationPidFileWriter is used).
    # 要写入的PID文件的位置(如果使用了ApplicationPidFileWriter)
#    file:
  # PROFILES
#  profiles:
    # Comma-separated list (or list if using YAML) of active profiles.
    # 活动的配置文件集的逗号分隔列表
#    active:
    # Unconditionally activate the specified comma separated profiles (or list of profiles if using YAML).
    # 无条件激活指定的逗号分隔的配置文件集(对所有环境都是相同配置值的必须配置)
#    include:
  http:
    # HTTP message conversion
#    converters:
      # Preferred JSON mapper to use for HTTP message conversion.
      # 用于HTTP消息转换的首选JSON映射器
#      preferred-json-mapper: jackson
    # HTTP encoding (HttpEncodingProperties)
#    encoding:
      # Charset of HTTP requests and responses. Added to the "Content-Type" header if not set explicitly.
      # HTTP请求和响应的字符集。如果未明确设置,则添加到"Content-Type"头信息中
#      charset: UTF-8
      # Enable http encoding support. 启用HTTP编码支持
#      enabled: true
    # MULTIPART (MultipartProperties) 文件上传
    multipart:
      # Enable support of multi-part uploads.
      # 启用对文件多部分上传的支持
      enabled: true
      # Max file size. 最大文件大小
#      max-file-size: 1MB
      # Max request size. 最大请求大小
#      max-request-size: 10MB
      # Whether to resolve the multipart request lazily at the time of file or parameter access.
      # 在文件或参数访问时是否延迟解析多部分请求
      resolve-lazily: true
  # JACKSON (JacksonProperties)
  jackson:
    # Date format string or a fully-qualified date format class name.
    # 日期格式字符串或完全限定日期格式类名称
    date-format: yyyy-MM-dd HH:mm:ss
    # Controls the inclusion of properties during serialization.
    # 控制序列化期间属性的包含
    default-property-inclusion: always
    # Joda date time format string. If not configured, "date-format" will be used as a fallback if it is configured with a format string.
#    joda-date-time-format:
    # One of the constants on Jackson's PropertyNamingStrategy. Can also be a fully-qualified class name of a PropertyNamingStrategy subclass.
    # Jackson的属性名称策略接口的常量之一,也可以是其子类的完全限定类名称
    property-naming-strategy: LOWER_CAMEL_CASE
  # SPRING MVC (WebMvcProperties)
  mvc:
    async:
      # Amount of time (in milliseconds) before asynchronous request handling times out.
      # 异步请求处理超时之前的时间(毫秒)
      request-timeout: 1000
    # Date format to use.
    # 要使用的日期格式
    date-format: yyyy-MM-dd
    servlet:
      # Load on startup priority of the Spring Web Services servlet.
      # 加载servlet的启动优先级
      load-on-startup: 1


# ----------------------------------------
# WEB PROPERTIES
# Web环境属性集
# ----------------------------------------

# EMBEDDED SERVER CONFIGURATION (ServerProperties)
server:
  compression:
    # If response compression is enabled. 启用响应压缩
    enabled: true
    # Minimum response size that is required for compression to be performed.
    # 执行压缩所需的最小响应大小(2KB)
#    min-response-size: 2048
  # Time in milliseconds that connectors will wait for another HTTP request before closing the connection. When not set, the connector's container-specific default will be used. Use a value of -1 to indicate no (i.e. infinite) timeout.
  # 连接器在关闭连接之前将等待另一个HTTP请求的时间(毫秒)。未设置时,将使用连接器特定于容器的默认值。
  connection-timeout: 600000
  # Context path of the application. 应用程序的上下文路径
#  context-path:
  # Display name of the application. 应用程序的显示名称
#  display-name: application
#  error:
    # Path of the error controller. 错误控制器的路径
#    path: /error
  # Server HTTP port. 服务器HTTP请求端口
#  port: 8080
  # Path of the main dispatcher servlet.
  # 主调度程序的路径
#  servlet-path: /
  session:
    cookie:
      # Maximum age of the session cookie in seconds.
      # 会话cookie的最长期限(秒)
      max-age: 1800
    # Session timeout in seconds. 会话超时(秒)
    timeout: 1800
#  ssl:
    # Enable SSL support. 启用SSL支持
#    enabled: true
    # SSL protocol to use. 要使用的SSL协议
#    protocol: TLS
  tomcat:
    # Maximum queue length for incoming connection requests when all possible request processing threads are in use.
    # 当所有可能的请求处理线程都在使用时,进来的连接请求的最大队列长度
    accept-count: 1
    accesslog:
      # Buffer output such that it is only flushed periodically.
      # 缓冲输出,使其仅定期刷新
#      buffered: true
      # Directory in which log files are created. Can be relative to the tomcat base dir or absolute.
      # 在其中创建日志文件的目录,可以是tomcat基本目录的相对目录
#      directory: logs
      # Enable access log. 启用访问日志
      enabled: true
      # Date format to place in log file name. 要放在日志文件名中的日期格式
      file-date-format: .yyyy-MM-dd.HH
      # Format pattern for access logs. 访问日志的格式模式
#      pattern: common
      # Log file name prefix. 日志文件名前缀
      prefix: tomcat_access
      # Defer inclusion of the date stamp in the file name until rotate time.
      # 将日期时间戳包含在文件名中,直到轮换时间为止
#      rename-on-rotate: false
      # Set request attributes for IP address, Hostname, protocol and port used for the request.
      # 设置用于请求的IP地址,主机名,协议和端口的请求属性
#      request-attributes-enabled: false
      # Enable access log rotation. 启用访问日志循环输出
#      rotate: true
      # Log file name suffix. 日志文件名后缀
#      suffix: .log
    # Delay in seconds between the invocation of backgroundProcess methods.
    # 调用后台处理方法之间的延迟(秒)
#    background-processor-delay: 10
    # Maximum number of connections that the server will accept and process at any given time.
    # 服务器在任何给定时间接受和处理的最大连接数
    max-connections: 200
    # Maximum size in bytes of the HTTP post content.
    # HTTP发布内容的最大字节大小(2MB)
#    max-http-post-size: 2097152
    # Maximum amount of worker threads. 最大工作者线程数
#    max-threads: 200
    # Minimum amount of worker threads. 最小工作者线程数
#    min-spare-threads: 10
    # Character encoding to use to decode the URI.
    # 用于解码URI的字符编码
#    uri-encoding: UTF-8

# SPRING SESSION (SessionProperties)


# ----------------------------------------
# SECURITY PROPERTIES
# 安全属性集
# ----------------------------------------

# SECURITY (SecurityProperties)
security:
  basic:
    # Enable basic authentication. 启用基本的身份验证
    enabled: true
    # Comma-separated list of paths to secure. 以逗号分隔的安全路径列表
    path: /**
  # Enable Cross Site Request Forgery support. 启用跨站点请求伪造支持
  enable-csrf: false
  # Security filter chain order. 安全筛选器链的顺序
  filter-order: 0
  # Security filter chain dispatcher types. 安全筛选器链的调度程序类型
  filter-dispatcher-types: ASYNC, FORWARD, INCLUDE, REQUEST
  # Comma-separated list of paths to exclude from the default secured paths.
  ignored:


# ----------------------------------------
# DATA PROPERTIES
# 数据属性集
# ----------------------------------------

# DAO (PersistenceExceptionTranslationAutoConfiguration)

# ELASTICSEARCH (ElasticsearchProperties)

# DATASOURCE (DataSourceAutoConfiguration)

# REDIS (RedisProperties)

# TRANSACTION (TransactionProperties)


# ----------------------------------------
# INTEGRATION PROPERTIES
# 功能集成属性集
# ----------------------------------------

# ACTIVEMQ (ActiveMQProperties)

# SPRING BATCH (BatchProperties)

# APACHE KAFKA (KafkaProperties)


# ----------------------------------------
# ACTUATOR PROPERTIES
# 执行器属性集
# ----------------------------------------

# ENDPOINTS (AbstractEndpoint subclasses)
endpoints:
  # Enable endpoints. 启用端点
  enabled: true
  actuator:
    # Enable the endpoint.
    enabled: true
    # Endpoint URL path. 端点URL路径
#    path:
#  autoconfig:
#  beans:
#  configprops:
#  docs:
#  dump:
#  env:
#  health:
#  heapdump:
#  info:
#  jolokia:
#  logfile:
#  loggers:
#  mappings:
#  metrics:
#  shutdown:
#  trace:
  # JMX ENDPOINT (EndpointMBeanExportProperties)
  jmx:
    # JMX domain name. Initialized with the value of 'spring.jmx.default-domain' if set.
    domain:
    # Enable JMX export of all endpoints. 启用所有端点的JMX导出
    enabled: true

# JOLOKIA (JolokiaProperties)

# MANAGEMENT HTTP SERVER (ManagementServerProperties)
management:
  # Management endpoint HTTP port. Uses the same port as the application by default. Configure a different port to use management-specific SSL.
  # 管理端点的HTTP端口。默认情况下,使用与应用程序相同的端口。
  port:
  security:
    # Accessing sensitive endpoints
    # Enable security. 启用安全性
    enabled: false
  # HEALTH INDICATORS
  health:
    # Enable default health indicators. 启用默认的运行状况指示器
    defaults:
      enabled: true
    # Enable disk space health check.
    diskspace:
      enabled: true
  # TRACING (TraceProperties)
  trace:
    # Items to be included in the trace. 要包含在追踪中的项目
    include: request-headers,response-headers,cookies,errors

# METRICS EXPORT (MetricExportProperties)


# ----------------------------------------
# DEVTOOLS PROPERTIES
# 开发工具箱属性集
# ----------------------------------------

# DEVTOOLS (DevToolsProperties)


# ----------------------------------------
# TESTING PROPERTIES
# 测试属性
# ----------------------------------------


祝大家玩得开心!ˇˍˇ

简放,杭州

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
### 回答1: dynamic-datasource-spring-boot-starter是一个基于Spring Boot的动态数据源管理工具。它提供了一种简单而强大的方式来配置和管理多个数据源,并能在运行时动态切换数据源。 在3.4.1版本中,该工具进行了一些改进和增强。首先,它支持了Spring Boot 2.x版本,这意味着我们可以在使用最新版本的Spring Boot框架的同时,依然能够使用该工具来管理数据源。 此外,3.4.1版本对多数据源的配置进行了优化,使得配置更加简洁和灵活。我们可以通过在application.properties或application.yml配置文件中指定数据源相关的属性来定义多个数据源,而不再需要编写繁琐的代码。 另外一项改进是在动态数据源切换方面。在之前的版本中,我们需要手动编写代码来切换数据源,而在3.4.1版本中,该工具已经提供了自动切换数据源的功能。我们只需要在需要切换数据源的方法或类上加上@DS注解,并指定要切换的数据源,即可实现自动切换数据源的功能。 最后值得一提的是,dynamic-datasource-spring-boot-starter 3.4.1还提供了一些其他的功能和特性,比如数据源监控,可扩展性和高可用性等。这些功能使得该工具在实际项目中的使用更加方便和可靠。 综上所述,dynamic-datasource-spring-boot-starter 3.4.1是一个功能强大、易于使用的动态数据源管理工具,它适用于Spring Boot框架,并在多数据源配置和动态数据源切换方面进行了改进和优化。它的出现为我们开发和管理多数据源的项目提供了便利,同时也提高了项目的可维护性和灵活性。 ### 回答2: dynamic-datasource-spring-boot-starter是一个基于Spring Boot的动态数据源管理的工具包。它提供了一种简单而灵活的方式来配置和管理多数据源。 首先,dynamic-datasource-spring-boot-starter可以方便地成到Spring Boot项目中。通过在pom.xml文件中引入相应的依赖,即可将该工具包引入项目中。然后,在application.yml文件中进行相应的配置,即可使用该工具包提供的功能。 其次,dynamic-datasource-spring-boot-starter可以轻松地配置多数据源。在配置文件中,可以指定多个数据源的连接信息,包括数据库的url、用户名、密码等。在需要使用数据源的地方,可以通过@DS注解来指定要使用的数据源。这样,就可以很方便地切换不同的数据源,实现读写分离或者分库分表等需求。 此外,dynamic-datasource-spring-boot-starter还提供了一些高级功能。比如,支持动态添加和删除数据源,可以在程序运行中动态地切换数据源;支持AOP切面,方便地对方法进行切面处理;支持多数据源的事务管理,保证了数据的一致性。 总之,dynamic-datasource-spring-boot-starter是一个功能强大而又灵活的动态数据源管理工具包。它使得在Spring Boot项目中配置和管理多数据源变得非常简单和方便,可以满足各种复杂的数据源切换和管理需求。它的出现极大地简化了多数据源的配置和管理工作,同时提供了一些高级功能,使得开发人员可以更加专注于业务逻辑的实现。 ### 回答3: dynamic-datasource-spring-boot-starter 3.4.1 是一个用于Spring Boot项目的动态数据源管理工具。它提供了一种简单而强大的方式来配置和管理多个数据源。 动态数据源管理是在一个应用程序中使用多个数据源的一种常见需求。通过使用 dynamic-datasource-spring-boot-starter,我们可以在一个Spring Boot应用程序中轻松地设置和切换多个数据源。 使用 dynamic-datasource-spring-boot-starter 的好处之一是它能够自动根据配置文件中的信息来创建和管理数据源。我们只需要在配置文件中指定要使用的数据源的名称、连接信息、用户名和密码等,dynamic-datasource-spring-boot-starter 就能自动根据这些信息创建数据源,并将其注册到应用程序的数据源管理器中。 另一个优点是 dynamic-datasource-spring-boot-starter 支持动态切换数据源。在应用程序运行时,我们可以通过调用相应的API来切换数据源。这在一些需要根据用户角色或环境设置不同数据源的场景中非常有用。 除了基本的数据源管理功能,dynamic-datasource-spring-boot-starter 还提供了一些其他有用的特性,例如动态创建数据源、多数据源的事务管理、数据源监控和统计等。 总而言之,dynamic-datasource-spring-boot-starter 3.4.1 是一个强大的工具,它简化了在Spring Boot应用程序中创建和管理多个数据源的过程,并提供了一些额外的功能来满足不同场景下的需求。如果你的应用程序需要使用多个数据源,dynamic-datasource-spring-boot-starter 可能是一个很好的选择。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

广益_简放

书写,深度思考,深刻理解

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值