【spring boot】配置資訊
1、feign 超時配置
2、上傳檔案大小控制
3、jackson的配置
4、@value 註解
5、日誌配置
1、feign 超時配置
feign:client:
config:
default:
connect-timeout: 600000
read-timeout: 600000
2、上傳檔案大小控制
multipart.maxfilesize=10mb是設定單個檔案的大小,
multipart.maxrequestsize=100mb是設定單次請求的檔案的總大小
如果是想要不限制檔案上傳的大小,那麼就把兩個值都設定為-1
如果前端走 nginx 需要修改 client_max_body_size 200m;
參考:
proxy_redirect off;proxy_set_header host $host;proxy_set_header x-real-ip $remote_addr;proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;client_max_body_size 200m;client_body_buffer_size 128k;proxy_connect_timeout 300;
方式一
spring:servlet:
multipart:
max-file-size: 10mb
max-request-size: 10mb
方式二
spring boot1.4版本後配置更改為:spring boot2.0之後的版本配置修改為:
spring.servlet.multipart.max-file-size=10mb
spring.servlet.multipart.max-request-size=10mb
方式三
/** * 檔案上傳配置
* @return */
@bean
public multipartconfigelement multipartconfigelement()
3、jackson的配置
spring:jackson:
date-format: yyyy-mm-dd
hh:mm:ss
time-zone: gmt+8
default-property-inclusion: non_null
4、@value 註解
@value("$")string maxfilesize;
:冒號後邊是預設值
@value("$")
string maxfilesize;
也可用spel表示式指定,如指定為null
@value("$}")
string maxfilesize;
5、日誌配置
預設:logback-spring.xml
自定義
logging:config: classpath
:logback-custom.xml
springboot配置資訊
server.context path center 應用上下文,在所有的controller之前 server.servlet path html 拼接在controller後面,eg http localhost 8080 center index.html server.servlet.con...
SpringBoot讀取配置資訊
配置檔案 服務埠號 server port 8081 proper key id value test123 demo val autoinject1.environment 讀取 使用方式 restcontroller public class democontroller 2.value 註解方...
配置資訊 類
常用的配置包括 資料庫連線,系統配置 檔案分布之類 應用配置 業務邏輯資料 其它 為方便程式獲取配置資訊,設計此類 獲取配置資訊類 class sconfig private static database 快取資料庫配置資訊 private static system 快取系統配置資訊 priva...