mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
refactor(core): 重构WebPriorityHeader相关配置类并优化结构
- 将PriorityHeaderConfiguration重命名为PriorityHeaderInitBinder以明确用途 - 合并RestTemplate配置至新创建的WebCommonConfiguration类 - 在WebCommonConfiguration中统一管理Web相关Bean配置 - 添加ConditionalOnWebApplication条件注解确保Servlet环境
This commit is contained in:
1 parent
bf8b8805c8
commit
37035cbf27
2 files changed
+28
-7
No files matched your search
+1
-1
@@ -11,7 +11,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ExtendedServletRequ
|
||||
* @date 2025/04/16
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class PriorityHeaderConfiguration {
|
||||
public class PriorityHeaderInitBinder {
|
||||
|
||||
/**
|
||||
* 初始化绑定器
|
||||
+27
-6
@@ -17,20 +17,41 @@
|
||||
|
||||
package com.pig4cloud.pigx.common.core.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* 通用Web配置类:提供RestTemplate的Bean配置
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2018/8/16 RestTemplate
|
||||
* @date 2025/05/01
|
||||
*/
|
||||
@Configuration
|
||||
public class RestTemplateConfiguration {
|
||||
public class WebCommonConfiguration {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
/**
|
||||
* 创建并配置RestTemplate的Bean方法
|
||||
*
|
||||
* @return RestTemplate实例
|
||||
*/
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建并返回{@link PriorityHeaderInitBinder}的Bean实例。
|
||||
*
|
||||
* @return PriorityHeaderInitBinder的实例对象
|
||||
* @condition 当Web应用程序类型为SERVLET时条件成立
|
||||
* @see PriorityHeaderInitBinder
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
public PriorityHeaderInitBinder priorityHeaderInitBinder() {
|
||||
return new PriorityHeaderInitBinder();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user