如何入侵自己做的網(wǎng)站網(wǎng)絡營銷最基本的應用方式是什么
????????在Spring Boot中,`application.properties` 和 `application.yml` 文件用于配置應用程序的各個方面,如服務器端口、數(shù)據(jù)庫連接、日志級別等。這兩個文件是Spring Boot的配置文件,位于 `src/main/resources` 目錄下。
????????application.properties 示例
????????`application.properties` 文件使用鍵值對的格式進行配置:
# 設置服務器端口
server.port=8080
# 數(shù)據(jù)庫配置
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=myuser
spring.datasource.password=mypassword
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# 日志配置
logging.level.root=INFO
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR
# Thymeleaf 配置
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.cache=false
????????application.yml 示例
????????`application.yml` 文件使用 YAML(Yet Another Markup Language)格式,它是一種直觀的能夠被電腦讀取的數(shù)據(jù)序列化格式,并且易于人類閱讀。它是JSON的一個超集。
# 設置服務器端口
server:port: 8080
# 數(shù)據(jù)庫配置
spring:datasource:url: jdbc:mysql://localhost:3306/mydbusername: myuserpassword: mypassworddriver-class-name: com.mysql.cj.jdbc.Driver
# 日志配置
logging:level:root: INFOorg.springframework.web: DEBUGorg.hibernate: ERROR
# Thymeleaf 配置
thymeleaf:prefix: classpath:/templates/suffix: .htmlmode: HTMLencoding: UTF-8cache: false
????????在 `application.yml` 文件中,可以使用縮進來表示層級關系,使得配置更加清晰。
????????注意事項
- `application.properties` 和 `application.yml` 可以同時存在,但是 `application.properties` 中的配置會覆蓋 `application.yml` 中的同名配置。
- `application.yml` 支持數(shù)組或列表的配置,例如:`myprops: [~, ~]`。
- 在 `application.yml` 中,冒號 `:` 后面必須有一個空格。
- `application.yml` 支持多文檔塊,可以在同一個文件中分隔多個配置文檔。
????????選擇 `application.properties` 還是 `application.yml` 主要取決于個人喜好和項目需求。YAML格式在處理復雜配置時可能更加直觀和易于管理。