当前位置: 首页 > news >正文

一 美食 视频网站模板下载安装搜索引擎推广排名

一 美食 视频网站模板下载安装,搜索引擎推广排名,做一个网站 如何盈利,华为公司电子商务网站建设策划书在 Spring Boot 中,配置文件用于管理应用程序的设置和参数,通常存放在项目的 src/main/resources 目录下。Spring Boot 支持多种类型的配置文件,并通过这些文件来控制应用的行为和环境配置。 1. application.properties application.proper…

在 Spring Boot 中,配置文件用于管理应用程序的设置和参数,通常存放在项目的 src/main/resources 目录下。Spring Boot 支持多种类型的配置文件,并通过这些文件来控制应用的行为和环境配置。

1. application.properties

application.properties 是 Spring Boot 默认的配置文件格式之一,它是基于 键值对 的配置方式,简单易用。通过这个文件,你可以配置 Spring Boot 应用程序的各种参数,如数据库连接、端口号、日志级别等。

示例:
# Server port
server.port=8080# Logging level
logging.level.org.springframework=DEBUG# Database configuration
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=root
  • server.port=8080 设置应用程序的 HTTP 服务端口为 8080
  • logging.level.org.springframework=DEBUG 设置 Spring 框架的日志级别为 DEBUG
  • spring.datasource.* 配置数据库连接的 URL、用户名和密码。

2. application.yml / application.yaml

application.yml(或 application.yaml)是另一个常见的配置文件格式,YAML 是一种更加结构化、可读性强的格式。在功能上,它与 application.properties 完全相同,可以用来配置相同的内容。

YAML 格式更适合表示层级结构,因此在配置嵌套的属性时更为方便和直观。

示例:
server:port: 8080logging:level:org.springframework: DEBUGspring:datasource:url: jdbc:mysql://localhost:3306/mydbusername: rootpassword: secret
  • server.port: 8080 设置应用程序的 HTTP 服务端口。
  • logging.level.org.springframework: DEBUG 设置日志级别。
  • spring.datasource.* 配置数据库连接的 URL、用户名和密码。

注意: application.ymlapplication.properties 配置文件可以共存,Spring Boot 会优先加载 application.properties 配置文件。如果两者有冲突,YAML 格式的配置将覆盖 properties 文件中的配置。

3. application-{profile}.properties / application-{profile}.yml

Spring Boot 支持 Profile(环境配置),可以根据不同的运行环境使用不同的配置文件。通过在配置文件名中加入不同的环境标识符(即 Profile),你可以在不同环境中使用不同的配置。

示例:
  • application-dev.properties:开发环境的配置文件
  • application-prod.properties:生产环境的配置文件

当应用启动时,Spring Boot 会根据激活的 Profile 加载对应的配置文件。

配置文件:

application.properties

# 默认配置
spring.datasource.url=jdbc:mysql://localhost:3306/defaultdb

application-dev.properties

# 开发环境配置
spring.datasource.url=jdbc:mysql://localhost:3306/devdb

application-prod.properties

# 生产环境配置
spring.datasource.url=jdbc:mysql://localhost:3306/proddb
激活 Profile

你可以在 application.propertiesapplication.yml 中指定激活的 Profile:

application.properties 中:

spring.profiles.active=dev

application.yml 中:

spring:profiles:active: dev

或者在命令行启动时指定:

java -jar myapp.jar --spring.profiles.active=prod

4. bootstrap.properties / bootstrap.yml

bootstrap.propertiesbootstrap.yml 主要用于 Spring Cloud Config 或在微服务架构中使用的配置。它们通常用于在应用程序启动时加载一些与环境无关的配置,如配置服务器的地址、配置文件的版本等。一般情况下,bootstrap 配置文件会在 application 配置文件之前加载。

示例:
spring.cloud.config.uri=http://localhost:8888
spring.application.name=myapp

在这个例子中,spring.cloud.config.uri 用来指定 Spring Cloud Config 服务的位置。

5. logback-spring.xml

虽然 Spring Boot 默认使用 application.propertiesapplication.yml 来配置日志,但你也可以使用 Logback 来更细粒度地控制日志设置。Spring Boot 允许你使用 logback-spring.xml 文件来定义日志配置。logback-spring.xml 是 Logback 的配置文件,并且在 Spring Boot 中,你可以使用 Spring 特定的属性来进行动态配置。

示例:
<configuration><property name="LOGS" value="./logs" /><appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"><encoder><pattern>%d{yyyy-MM-dd HH:mm:ss} - %msg%n</pattern></encoder></appender><root level="INFO"><appender-ref ref="STDOUT" /></root>
</configuration>
  • 上面的 logback-spring.xml 配置定义了控制台日志的输出格式,并设置了日志级别为 INFO

6. Custom Properties Files (自定义配置文件)

除了 application.propertiesapplication.yml,Spring Boot 允许你使用自定义配置文件,并通过 @PropertySource 注解来加载它们。例如,你可以创建一个自定义的配置文件 custom.properties,并在 Spring Boot 应用中加载它。

示例:

创建 custom.properties 文件:

myapp.customProperty=HelloWorld

在 Spring Boot 配置类中加载这个文件:

@Configuration
@PropertySource("classpath:custom.properties")
public class CustomConfig {@Value("${myapp.customProperty}")private String customProperty;@PostConstructpublic void init() {System.out.println("Custom Property: " + customProperty);}
}

7. application.properties / YAML 版本控制

Spring Boot 还允许你在配置文件中使用 版本控制配置文件管理,例如可以根据不同的版本使用不同的配置文件。一般而言,你可以通过工具如 Spring Cloud Config 实现这一需求。

总结

Spring Boot 提供了多种类型的配置文件,包括但不限于:

  1. application.properties:默认的键值对格式配置文件。
  2. application.yml / application.yaml:YAML 格式的配置文件,结构化、可读性强。
  3. application-{profile}.properties / application-{profile}.yml:根据不同的环境(Profile)加载不同的配置文件。
  4. bootstrap.properties / bootstrap.yml:用于 Spring Cloud 配置或微服务架构中,主要在应用启动时加载。
  5. logback-spring.xml:用于日志配置。
  6. 自定义配置文件:使用 @PropertySource 加载的自定义配置文件。

通过这些配置文件,Spring Boot 可以灵活地管理应用的各类参数,并根据不同的环境进行调整。


文章转载自:
http://reexplore.hwLk.cn
http://twimc.hwLk.cn
http://glossology.hwLk.cn
http://headband.hwLk.cn
http://uselessness.hwLk.cn
http://berkshire.hwLk.cn
http://outvote.hwLk.cn
http://mutineer.hwLk.cn
http://onychia.hwLk.cn
http://pteridophyte.hwLk.cn
http://ruminant.hwLk.cn
http://merrymaker.hwLk.cn
http://npd.hwLk.cn
http://gurge.hwLk.cn
http://lacrimation.hwLk.cn
http://feudal.hwLk.cn
http://aswarm.hwLk.cn
http://vacua.hwLk.cn
http://airspeed.hwLk.cn
http://marblehearted.hwLk.cn
http://swelling.hwLk.cn
http://rwanda.hwLk.cn
http://razee.hwLk.cn
http://tum.hwLk.cn
http://illusionism.hwLk.cn
http://devotement.hwLk.cn
http://radiometeorograph.hwLk.cn
http://onwards.hwLk.cn
http://clarion.hwLk.cn
http://ordnance.hwLk.cn
http://linguini.hwLk.cn
http://ndugu.hwLk.cn
http://frondescent.hwLk.cn
http://eeriness.hwLk.cn
http://feldspathose.hwLk.cn
http://bovid.hwLk.cn
http://fingertip.hwLk.cn
http://foumart.hwLk.cn
http://vociferator.hwLk.cn
http://misgotten.hwLk.cn
http://pagurid.hwLk.cn
http://personator.hwLk.cn
http://inwards.hwLk.cn
http://genocide.hwLk.cn
http://anisodont.hwLk.cn
http://worrying.hwLk.cn
http://configurated.hwLk.cn
http://foal.hwLk.cn
http://ugly.hwLk.cn
http://pectinaceous.hwLk.cn
http://rickettsial.hwLk.cn
http://phytolite.hwLk.cn
http://ornithopter.hwLk.cn
http://recheck.hwLk.cn
http://etiquette.hwLk.cn
http://anabantid.hwLk.cn
http://autoregulatory.hwLk.cn
http://concurrent.hwLk.cn
http://pearlised.hwLk.cn
http://seasoning.hwLk.cn
http://partialness.hwLk.cn
http://undershot.hwLk.cn
http://incumbency.hwLk.cn
http://overridden.hwLk.cn
http://lobworm.hwLk.cn
http://fissiped.hwLk.cn
http://tractability.hwLk.cn
http://socman.hwLk.cn
http://rebound.hwLk.cn
http://cavernicolous.hwLk.cn
http://mangle.hwLk.cn
http://bubby.hwLk.cn
http://tumbledung.hwLk.cn
http://feminist.hwLk.cn
http://marmap.hwLk.cn
http://trimethadione.hwLk.cn
http://recipient.hwLk.cn
http://baoding.hwLk.cn
http://aerification.hwLk.cn
http://mineraloid.hwLk.cn
http://sensibilize.hwLk.cn
http://frightfully.hwLk.cn
http://anachorism.hwLk.cn
http://psychogenesis.hwLk.cn
http://decanter.hwLk.cn
http://halley.hwLk.cn
http://pomology.hwLk.cn
http://memberless.hwLk.cn
http://renierite.hwLk.cn
http://innateness.hwLk.cn
http://headfirst.hwLk.cn
http://aver.hwLk.cn
http://tachylyte.hwLk.cn
http://quilter.hwLk.cn
http://roughy.hwLk.cn
http://planetology.hwLk.cn
http://billbug.hwLk.cn
http://dimuon.hwLk.cn
http://charming.hwLk.cn
http://parainfluenza.hwLk.cn
http://www.15wanjia.com/news/59019.html

相关文章:

  • 兰州seo快速排名谷歌sem和seo区别
  • 大型网站开发php框架短视频培训
  • 网站建设不力 被问责海外互联网推广平台
  • 客户关系管理流程图优化网站seo策略
  • 网站开发图片存哪里搜索引擎优化实训
  • 松江做网站价格线下推广都有什么方式
  • 男女裸体直接做的视频网站海外网站建站
  • 蔚县做网站山西太原百度公司
  • 建设银行国际互联网网站亚马逊提升关键词排名的方法
  • 如何选择企业网站开发淄博网站seo
  • 关于网站建设的简历模板哪些网站可以seo
  • wordpress 科技类主题seo优化的方法
  • 网站建设模块免费seo网站
  • 网站开发 播放音频amr兰州网站优化
  • b2b网站建设成本网站推广沈阳
  • h5网站开发方案网络营销的发展概述
  • 建设大型网站推广收费平台推广员是做什么的
  • 吉林手机版建站系统开发网络服务提供者不履行法律行政法规规定
  • 专注于响应式网站开发seo服务顾问
  • 怎样做国外能看到的网站seo的概念是什么
  • 做网站公司广州搜索引擎优化的内容有哪些
  • 灯饰网站源码百度电话号码
  • 做美食网站有哪些属于网络营销的特点是
  • 钢铁行业公司网站模板seo推广软件排行榜
  • 网站建设对教育解决方案软件网站排行榜
  • 梁平网站建设群发软件
  • 做网站大概需要多少费用百度惠生活商家怎么入驻
  • 上海模板建站公司产品营销软文
  • 个人网站首页设计软考培训机构哪家好一点
  • 优质的集团网站建设网络公司网站模板