优化,使用 @Configuration(proxyBeanMethods = false) 提升启动速度

This commit is contained in:
YunaiV 2022-11-12 20:17:58 +08:00
parent 92ace031fe
commit f5ef87094d
28 changed files with 30 additions and 27 deletions

View File

@ -9,7 +9,7 @@ import org.springframework.context.annotation.Configuration;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
public class YudaoBannerAutoConfiguration { public class YudaoBannerAutoConfiguration {
@Bean @Bean

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Configuration @Configuration(proxyBeanMethods = false)
public class YudaoDictAutoConfiguration { public class YudaoDictAutoConfiguration {
@Bean @Bean

View File

@ -17,7 +17,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "yudao.error-code", value = "enable", matchIfMissing = true) // 允许使用 yudao.error-code.enable=false 禁用访问日志 @ConditionalOnProperty(prefix = "yudao.error-code", value = "enable", matchIfMissing = true) // 允许使用 yudao.error-code.enable=false 禁用访问日志
@EnableConfigurationProperties(ErrorCodeProperties.class) @EnableConfigurationProperties(ErrorCodeProperties.class)
@EnableScheduling // 开启调度任务的功能因为 ErrorCodeRemoteLoader 通过定时刷新错误码 @EnableScheduling // 开启调度任务的功能因为 ErrorCodeRemoteLoader 通过定时刷新错误码

View File

@ -7,7 +7,7 @@ import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Configuration @Configuration(proxyBeanMethods = false)
public class YudaoOperateLogAutoConfiguration { public class YudaoOperateLogAutoConfiguration {
@Bean @Bean

View File

@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(PayProperties.class) @EnableConfigurationProperties(PayProperties.class)
public class YudaoPayAutoConfiguration { public class YudaoPayAutoConfiguration {

View File

@ -10,7 +10,7 @@ import org.springframework.context.annotation.Configuration;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
public class YudaoSmsAutoConfiguration { public class YudaoSmsAutoConfiguration {
@Bean @Bean

View File

@ -19,7 +19,7 @@ import org.springframework.context.annotation.Primary;
* @date 2021-10-30 * @date 2021-10-30
*/ */
@Slf4j @Slf4j
@Configuration @Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(JustAuthProperties.class) @EnableConfigurationProperties(JustAuthProperties.class)
public class YudaoSocialAutoConfiguration { public class YudaoSocialAutoConfiguration {

View File

@ -35,7 +35,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import java.util.Objects; import java.util.Objects;
@Configuration @Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(prefix = "yudao.tenant", value = "enable", matchIfMissing = true) // 允许使用 yudao.tenant.enable=false 禁用多租户 @ConditionalOnProperty(prefix = "yudao.tenant", value = "enable", matchIfMissing = true) // 允许使用 yudao.tenant.enable=false 禁用多租户
@EnableConfigurationProperties(TenantProperties.class) @EnableConfigurationProperties(TenantProperties.class)
public class YudaoTenantAutoConfiguration { public class YudaoTenantAutoConfiguration {

View File

@ -8,7 +8,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
@Configuration @Configuration(proxyBeanMethods = false)
public class YudaoCaptchaConfiguration { public class YudaoCaptchaConfiguration {
static { static {

View File

@ -10,7 +10,7 @@ import org.springframework.context.annotation.Configuration;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
public class YudaoFileAutoConfiguration { public class YudaoFileAutoConfiguration {
@Bean @Bean

View File

@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncListenableTaskExecutor; import org.springframework.core.task.AsyncListenableTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@Configuration @Configuration(proxyBeanMethods = false)
public class YudaoFlowableConfiguration { public class YudaoFlowableConfiguration {
/** /**

View File

@ -11,7 +11,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/** /**
* 异步任务 Configuration * 异步任务 Configuration
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@EnableAsync @EnableAsync
public class YudaoAsyncAutoConfiguration { public class YudaoAsyncAutoConfiguration {

View File

@ -9,7 +9,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
/** /**
* 定时任务 Configuration * 定时任务 Configuration
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@EnableScheduling // 开启 Spring 自带的定时任务 @EnableScheduling // 开启 Spring 自带的定时任务
public class YudaoQuartzAutoConfiguration { public class YudaoQuartzAutoConfiguration {

View File

@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@ConditionalOnClass({MeterRegistryCustomizer.class}) @ConditionalOnClass({MeterRegistryCustomizer.class})
@ConditionalOnProperty(prefix = "yudao.metrics", value = "enable", matchIfMissing = true) // 允许使用 yudao.metrics.enable=false 禁用 Metrics @ConditionalOnProperty(prefix = "yudao.metrics", value = "enable", matchIfMissing = true) // 允许使用 yudao.metrics.enable=false 禁用 Metrics
public class YudaoMetricsAutoConfiguration { public class YudaoMetricsAutoConfiguration {

View File

@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration;
* *
* @author mashu * @author mashu
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@ConditionalOnClass({BizTraceAspect.class}) @ConditionalOnClass({BizTraceAspect.class})
@EnableConfigurationProperties(TracerProperties.class) @EnableConfigurationProperties(TracerProperties.class)
@ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true) @ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true)

View File

@ -34,7 +34,7 @@ import java.util.Properties;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@AutoConfigureAfter(YudaoRedisAutoConfiguration.class) @AutoConfigureAfter(YudaoRedisAutoConfiguration.class)
@Slf4j @Slf4j
public class YudaoMQAutoConfiguration { public class YudaoMQAutoConfiguration {

View File

@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理 @EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理
@EnableConfigurationProperties(DruidStatProperties.class) @EnableConfigurationProperties(DruidStatProperties.class)
public class YudaoDataSourceAutoConfiguration { public class YudaoDataSourceAutoConfiguration {

View File

@ -23,7 +23,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class, @MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class,
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载目前仅用于单元测试 lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载目前仅用于单元测试
public class YudaoMybatisAutoConfiguration { public class YudaoMybatisAutoConfiguration {

View File

@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Configuration @Configuration(proxyBeanMethods = false)
@AutoConfigureBefore(LockAutoConfiguration.class) @AutoConfigureBefore(LockAutoConfiguration.class)
public class YudaoLock4jConfiguration { public class YudaoLock4jConfiguration {

View File

@ -13,7 +13,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
/** /**
* Cache 配置类基于 Redis 实现 * Cache 配置类基于 Redis 实现
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({CacheProperties.class}) @EnableConfigurationProperties({CacheProperties.class})
@EnableCaching @EnableCaching
public class YudaoCacheAutoConfiguration { public class YudaoCacheAutoConfiguration {

View File

@ -9,7 +9,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
/** /**
* Redis 配置类 * Redis 配置类
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
public class YudaoRedisAutoConfiguration { public class YudaoRedisAutoConfiguration {
/** /**

View File

@ -32,7 +32,7 @@ import java.util.Set;
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {

View File

@ -19,7 +19,7 @@ import org.springframework.context.annotation.Configuration;
import javax.servlet.Filter; import javax.servlet.Filter;
@Configuration @Configuration(proxyBeanMethods = false)
@AutoConfigureAfter(YudaoWebAutoConfiguration.class) @AutoConfigureAfter(YudaoWebAutoConfiguration.class)
public class YudaoApiLogAutoConfiguration { public class YudaoApiLogAutoConfiguration {

View File

@ -13,8 +13,8 @@ import org.springframework.context.annotation.Configuration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Configuration(proxyBeanMethods = false)
@Slf4j @Slf4j
@Configuration
public class YudaoJacksonAutoConfiguration { public class YudaoJacksonAutoConfiguration {
@Bean @Bean

View File

@ -29,7 +29,7 @@ import static springfox.documentation.builders.RequestHandlerSelectors.basePacka
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration(proxyBeanMethods = false)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j @EnableKnife4j
@ConditionalOnClass({Docket.class, ApiInfoBuilder.class}) @ConditionalOnClass({Docket.class, ApiInfoBuilder.class})

View File

@ -26,7 +26,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.Filter; import javax.servlet.Filter;
@Configuration @Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({WebProperties.class, XssProperties.class}) @EnableConfigurationProperties({WebProperties.class, XssProperties.class})
public class YudaoWebAutoConfiguration implements WebMvcConfigurer { public class YudaoWebAutoConfiguration implements WebMvcConfigurer {

View File

@ -60,7 +60,7 @@ public class AppTradeOrderController {
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("获得交易订单") @ApiOperation("获得交易订单")
@ApiImplicitParam(name = "tradeOrderId", value = "交易订单编号", required = true) @ApiImplicitParam(name = "tradeOrderId", value = "交易订单编号", required = true, dataTypeClass = Long.class)
public CommonResult<TradeOrderRespVO> getTradeOrder(@RequestParam("tradeOrderId") Integer tradeOrderId) { public CommonResult<TradeOrderRespVO> getTradeOrder(@RequestParam("tradeOrderId") Integer tradeOrderId) {
// return success(tradeOrderService.getTradeOrder(tradeOrderId)); // return success(tradeOrderService.getTradeOrder(tradeOrderId));
return null; return null;

View File

@ -22,6 +22,9 @@ public class YudaoServerApplication {
// 如果你碰到启动的问题请认真阅读 https://doc.iocoder.cn/quick-start/ 文章 // 如果你碰到启动的问题请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
SpringApplication.run(YudaoServerApplication.class, args); SpringApplication.run(YudaoServerApplication.class, args);
// new SpringApplicationBuilder(YudaoServerApplication.class)
// .applicationStartup(new BufferingApplicationStartup(20480))
// .run(args);
// 如果你碰到启动的问题请认真阅读 https://doc.iocoder.cn/quick-start/ 文章 // 如果你碰到启动的问题请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
// 如果你碰到启动的问题请认真阅读 https://doc.iocoder.cn/quick-start/ 文章 // 如果你碰到启动的问题请认真阅读 https://doc.iocoder.cn/quick-start/ 文章