[spring6: BeanPostProcessor BeanFactoryPostProcessor]-生命周期

BeanFactoryPostProcessor

BeanFactoryPostProcessor 接口允許在 Spring 容器初始化完所有的 bean 定義之后,但還未實例化任何 bean 時,修改應用上下文的內部 bean 工廠。通過實現 postProcessBeanFactory 方法,你可以覆蓋或添加屬性,甚至是對急切初始化的 beans 進行修改。

// AspectJWeavingEnabler, ConfigurationClassPostProcessor, CustomAutowireConfigurer, CustomEditorConfigurer, CustomScopeConfigurer, DeprecatedBeanWarner, EventListenerMethodProcessor, PlaceholderConfigurerSupport, PreferencesPlaceholderConfigurer, PropertyOverrideConfigurer, PropertyPlaceholderConfigurer, PropertyResourceConfigurer, PropertySourcesPlaceholderConfigurer
@FunctionalInterface
public interface BeanFactoryPostProcessor {/*** Modify the application context's internal bean factory after its standard* initialization. All bean definitions will have been loaded, but no beans* will have been instantiated yet. This allows for overriding or adding* properties even to eager-initializing beans.* @param beanFactory the bean factory used by the application context* @throws org.springframework.beans.BeansException in case of errors*/void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException;}

BeanDefinitionRegistryPostProcessor

BeanDefinitionRegistryPostProcessor 接口繼承自 BeanFactoryPostProcessor,允許在應用上下文的內部 bean 定義注冊表初始化之后(但還未實例化任何 bean)修改 bean 定義。通過實現 postProcessBeanDefinitionRegistry 方法,可以在下一個后處理階段之前,向容器中添加額外的 bean 定義。postProcessBeanFactory 方法默認是空實現,因為該接口主要關注 postProcessBeanDefinitionRegistry 方法。

// ConfigurationClassPostProcessor
public interface BeanDefinitionRegistryPostProcessor extends BeanFactoryPostProcessor {/*** Modify the application context's internal bean definition registry after its* standard initialization. All regular bean definitions will have been loaded,* but no beans will have been instantiated yet. This allows for adding further* bean definitions before the next post-processing phase kicks in.* @param registry the bean definition registry used by the application context* @throws org.springframework.beans.BeansException in case of errors*/void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException;/*** Empty implementation of {@link BeanFactoryPostProcessor#postProcessBeanFactory}* since custom {@code BeanDefinitionRegistryPostProcessor} implementations will* typically only provide a {@link #postProcessBeanDefinitionRegistry} method.* @since 6.1*/@Overridedefault void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {}}
實現類用途
AspectJWeavingEnabler啟用 AspectJ 編織支持,通常與 Spring AOP 集成使用,用于支持 AspectJ 注解的織入。
ConfigurationClassPostProcessor處理 Spring 配置類(使用 @Configuration 注解的類),執行配置類的 Bean 定義處理。
CustomAutowireConfigurer允許注冊自定義的自動注入限定符類型(如自定義注解),以擴展 Spring 的自動注入功能。
CustomEditorConfigurer為 Spring Bean 的屬性類型注冊自定義編輯器,以便在屬性賦值時進行類型轉換。
CustomScopeConfigurer配置 Spring 自定義作用域(例如,創建一個新的作用域或改變現有作用域的行為)。
DeprecatedBeanWarner提供警告,在 Spring Bean 配置中發現已棄用的 Bean 時發出警告。
EventListenerMethodProcessor處理使用 @EventListener 注解的方法,自動注冊為 Spring 應用上下文中的事件監聽器。
PlaceholderConfigurerSupport支持配置屬性的占位符替換,通常用于加載屬性文件并注入屬性值到 Bean 中。
PreferencesPlaceholderConfigurer允許從 java.util.prefs.Preferences 中加載占位符屬性,適用于 Java 的偏好設置。
PropertyOverrideConfigurer允許通過 XML 配置文件覆蓋現有的 Bean 屬性值,通常用于根據不同環境加載不同的配置。
PropertyPlaceholderConfigurer用于解析 properties 文件中的占位符并注入到 Spring 配置中的 Bean 屬性。
PropertyResourceConfigurer處理并加載資源文件(如 .properties 文件)中的占位符替換,常用于外部配置文件的支持。
PropertySourcesPlaceholderConfigurer替代 PropertyPlaceholderConfigurer,支持在 Spring 4 中對 PropertySources API 的擴展。

BeanFactoryInitializer

BeanFactoryInitializer 接口用于初始化給定的 beanFactory。它定義了一個方法 initialize,接收一個類型為 F extends ListableBeanFactorybeanFactory 參數,允許實現類對該 beanFactory 進行啟動或初始化設置。

public interface BeanFactoryInitializer<F extends ListableBeanFactory> {/*** Initialize the given bean factory.* @param beanFactory the bean factory to bootstrap*/void initialize(F beanFactory);}

BeanPostProcessor

BeanPostProcessor 接口允許在 Spring 容器初始化 bean 之前和之后對其進行自定義處理。通過實現這兩個方法:postProcessBeforeInitializationpostProcessAfterInitialization,你可以在 bean 初始化的各個階段修改 bean 實例或返回一個包裝的版本。

// AbstractAdvisingBeanPostProcessor, AbstractAdvisorAutoProxyCreator, AbstractAutoProxyCreator, AbstractBeanFactoryAwareAdvisingPostProcessor, AdvisorAdapterRegistrationManager, AnnotationAwareAspectJAutoProxyCreator, AspectJAwareAdvisorAutoProxyCreator, AsyncAnnotationBeanPostProcessor, AutowiredAnnotationBeanPostProcessor, BeanNameAutoProxyCreator, BeanValidationPostProcessor, CommonAnnotationBeanPostProcessor, DefaultAdvisorAutoProxyCreator, ImportAwareAotBeanPostProcessor, InfrastructureAdvisorAutoProxyCreator, InitDestroyAnnotationBeanPostProcessor, JmsListenerAnnotationBeanPostProcessor, LoadTimeWeaverAwareProcessor, MethodValidationPostProcessor, PersistenceAnnotationBeanPostProcessor, PersistenceExceptionTranslationPostProcessor, ScheduledAnnotationBeanPostProcessor, ScriptFactoryPostProcessor, ServletContextAwareProcessor, SimpleServletPostProcessor
public interface BeanPostProcessor {/*** Apply this {@code BeanPostProcessor} to the given new bean instance <i>before</i> any bean* initialization callbacks (like InitializingBean's {@code afterPropertiesSet}* or a custom init-method). The bean will already be populated with property values.* The returned bean instance may be a wrapper around the original.* <p>The default implementation returns the given {@code bean} as-is.* @param bean the new bean instance* @param beanName the name of the bean* @return the bean instance to use, either the original or a wrapped one;* if {@code null}, no subsequent BeanPostProcessors will be invoked* @throws org.springframework.beans.BeansException in case of errors* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet*/@Nullabledefault Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {return bean;}/*** Apply this {@code BeanPostProcessor} to the given new bean instance <i>after</i> any bean* initialization callbacks (like InitializingBean's {@code afterPropertiesSet}* or a custom init-method). The bean will already be populated with property values.* The returned bean instance may be a wrapper around the original.* <p>In case of a FactoryBean, this callback will be invoked for both the FactoryBean* instance and the objects created by the FactoryBean (as of Spring 2.0). The* post-processor can decide whether to apply to either the FactoryBean or created* objects or both through corresponding {@code bean instanceof FactoryBean} checks.* <p>This callback will also be invoked after a short-circuiting triggered by a* {@link InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation} method,* in contrast to all other {@code BeanPostProcessor} callbacks.* <p>The default implementation returns the given {@code bean} as-is.* @param bean the new bean instance* @param beanName the name of the bean* @return the bean instance to use, either the original or a wrapped one;* if {@code null}, no subsequent BeanPostProcessors will be invoked* @throws org.springframework.beans.BeansException in case of errors* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet* @see org.springframework.beans.factory.FactoryBean*/@Nullabledefault Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {return bean;}}

DestructionAwareBeanPostProcessor

DestructionAwareBeanPostProcessor 是一個擴展自 BeanPostProcessor 的接口,用于在 Spring 容器銷毀 bean 前執行自定義的銷毀操作,并可以判斷是否需要銷毀該 bean。

// CommonAnnotationBeanPostProcessor, InitDestroyAnnotationBeanPostProcessor, PersistenceAnnotationBeanPostProcessor, ScheduledAnnotationBeanPostProcessor, SimpleServletPostProcessor
public interface DestructionAwareBeanPostProcessor extends BeanPostProcessor {/*** Apply this BeanPostProcessor to the given bean instance before its* destruction, for example, invoking custom destruction callbacks.* <p>Like DisposableBean's {@code destroy} and a custom destroy method, this* callback will only apply to beans which the container fully manages the* lifecycle for. This is usually the case for singletons and scoped beans.* @param bean the bean instance to be destroyed* @param beanName the name of the bean* @throws org.springframework.beans.BeansException in case of errors* @see org.springframework.beans.factory.DisposableBean#destroy()* @see org.springframework.beans.factory.support.AbstractBeanDefinition#setDestroyMethodName(String)*/void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException;/*** Determine whether the given bean instance requires destruction by this* post-processor.* <p>The default implementation returns {@code true}. If a pre-5 implementation* of {@code DestructionAwareBeanPostProcessor} does not provide a concrete* implementation of this method, Spring silently assumes {@code true} as well.* @param bean the bean instance to check* @return {@code true} if {@link #postProcessBeforeDestruction} is supposed to* be called for this bean instance eventually, or {@code false} if not needed* @since 4.3*/default boolean requiresDestruction(Object bean) {return true;}}

InstantiationAwareBeanPostProcessor

InstantiationAwareBeanPostProcessor 是一個擴展自 BeanPostProcessor 的接口,用于在 Spring 容器實例化 bean 之前和之后進行自定義處理,允許修改 bean 實例化過程及其屬性設置。

// AbstractAdvisingBeanPostProcessor, AbstractAdvisorAutoProxyCreator, AbstractAutoProxyCreator, AbstractBeanFactoryAwareAdvisingPostProcessor, AnnotationAwareAspectJAutoProxyCreator, AspectJAwareAdvisorAutoProxyCreator, AsyncAnnotationBeanPostProcessor, AutowiredAnnotationBeanPostProcessor, BeanNameAutoProxyCreator, CommonAnnotationBeanPostProcessor, DefaultAdvisorAutoProxyCreator, InfrastructureAdvisorAutoProxyCreator, MethodValidationPostProcessor, PersistenceAnnotationBeanPostProcessor, PersistenceExceptionTranslationPostProcessor, ScriptFactoryPostProcessor
public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {/*** Apply this BeanPostProcessor <i>before the target bean gets instantiated</i>.* The returned bean object may be a proxy to use instead of the target bean,* effectively suppressing default instantiation of the target bean.* <p>If a non-null object is returned by this method, the bean creation process* will be short-circuited. The only further processing applied is the* {@link #postProcessAfterInitialization} callback from the configured* {@link BeanPostProcessor BeanPostProcessors}.* <p>This callback will be applied to bean definitions with their bean class,* as well as to factory-method definitions in which case the returned bean type* will be passed in here.* <p>Post-processors may implement the extended* {@link SmartInstantiationAwareBeanPostProcessor} interface in order* to predict the type of the bean object that they are going to return here.* <p>The default implementation returns {@code null}.* @param beanClass the class of the bean to be instantiated* @param beanName the name of the bean* @return the bean object to expose instead of a default instance of the target bean,* or {@code null} to proceed with default instantiation* @throws org.springframework.beans.BeansException in case of errors* @see #postProcessAfterInstantiation* @see org.springframework.beans.factory.support.AbstractBeanDefinition#getBeanClass()* @see org.springframework.beans.factory.support.AbstractBeanDefinition#getFactoryMethodName()*/@Nullabledefault Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {return null;}/*** Perform operations after the bean has been instantiated, via a constructor or factory method,* but before Spring property population (from explicit properties or autowiring) occurs.* <p>This is the ideal callback for performing custom field injection on the given bean* instance, right before Spring's autowiring kicks in.* <p>The default implementation returns {@code true}.* @param bean the bean instance created, with properties not having been set yet* @param beanName the name of the bean* @return {@code true} if properties should be set on the bean; {@code false}* if property population should be skipped. Normal implementations should return {@code true}.* Returning {@code false} will also prevent any subsequent InstantiationAwareBeanPostProcessor* instances being invoked on this bean instance.* @throws org.springframework.beans.BeansException in case of errors* @see #postProcessBeforeInstantiation*/default boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {return true;}/*** Post-process the given property values before the factory applies them* to the given bean.* <p>The default implementation returns the given {@code pvs} as-is.* @param pvs the property values that the factory is about to apply (never {@code null})* @param bean the bean instance created, but whose properties have not yet been set* @param beanName the name of the bean* @return the actual property values to apply to the given bean (can be the passed-in* PropertyValues instance), or {@code null} to skip property population* @throws org.springframework.beans.BeansException in case of errors* @since 5.1*/@Nullabledefault PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) throws BeansException {return pvs;}}

MergedBeanDefinitionPostProcessor

MergedBeanDefinitionPostProcessor 是一個擴展自 BeanPostProcessor 的接口,用于在合并后的 bean 定義過程中進行自定義處理,并允許在 bean 定義重置時清理相關元數據。

// AutowiredAnnotationBeanPostProcessor, CommonAnnotationBeanPostProcessor, InitDestroyAnnotationBeanPostProcessor, JmsListenerAnnotationBeanPostProcessor, PersistenceAnnotationBeanPostProcessor, ScheduledAnnotationBeanPostProcessor
public interface MergedBeanDefinitionPostProcessor extends BeanPostProcessor {/*** Post-process the given merged bean definition for the specified bean.* @param beanDefinition the merged bean definition for the bean* @param beanType the actual type of the managed bean instance* @param beanName the name of the bean* @see AbstractAutowireCapableBeanFactory#applyMergedBeanDefinitionPostProcessors*/void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName);/*** A notification that the bean definition for the specified name has been reset,* and that this post-processor should clear any metadata for the affected bean.* <p>The default implementation is empty.* @param beanName the name of the bean* @since 5.1* @see DefaultListableBeanFactory#resetBeanDefinition*/default void resetBeanDefinition(String beanName) {}}

SmartInstantiationAwareBeanPostProcessor

SmartInstantiationAwareBeanPostProcessor 擴展了 InstantiationAwareBeanPostProcessor,提供了一些額外的回調方法,用于預測、確定和操作 bean 類型、構造函數以及早期訪問的引用,支持更細粒度的 bean 創建和初始化控制。

// AbstractAdvisingBeanPostProcessor, AbstractAdvisorAutoProxyCreator, AbstractAutoProxyCreator, AbstractBeanFactoryAwareAdvisingPostProcessor, AnnotationAwareAspectJAutoProxyCreator, AspectJAwareAdvisorAutoProxyCreator, AsyncAnnotationBeanPostProcessor, AutowiredAnnotationBeanPostProcessor, BeanNameAutoProxyCreator, DefaultAdvisorAutoProxyCreator, InfrastructureAdvisorAutoProxyCreator, MethodValidationPostProcessor, PersistenceExceptionTranslationPostProcessor, ScriptFactoryPostProcessor
public interface SmartInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessor {/*** Predict the type of the bean to be eventually returned from this* processor's {@link #postProcessBeforeInstantiation} callback.* <p>The default implementation returns {@code null}.* Specific implementations should try to predict the bean type as* far as known/cached already, without extra processing steps.* @param beanClass the raw class of the bean* @param beanName the name of the bean* @return the type of the bean, or {@code null} if not predictable* @throws org.springframework.beans.BeansException in case of errors*/@Nullabledefault Class<?> predictBeanType(Class<?> beanClass, String beanName) throws BeansException {return null;}/*** Determine the type of the bean to be eventually returned from this* processor's {@link #postProcessBeforeInstantiation} callback.* <p>The default implementation returns the given bean class as-is.* Specific implementations should fully evaluate their processing steps* in order to create/initialize a potential proxy class upfront.* @param beanClass the raw class of the bean* @param beanName the name of the bean* @return the type of the bean (never {@code null})* @throws org.springframework.beans.BeansException in case of errors* @since 6.0*/default Class<?> determineBeanType(Class<?> beanClass, String beanName) throws BeansException {return beanClass;}/*** Determine the candidate constructors to use for the given bean.* <p>The default implementation returns {@code null}.* @param beanClass the raw class of the bean (never {@code null})* @param beanName the name of the bean* @return the candidate constructors, or {@code null} if none specified* @throws org.springframework.beans.BeansException in case of errors*/@Nullabledefault Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {return null;}/*** Obtain a reference for early access to the specified bean,* typically for the purpose of resolving a circular reference.* <p>This callback gives post-processors a chance to expose a wrapper* early - that is, before the target bean instance is fully initialized.* The exposed object should be equivalent to what* {@link #postProcessBeforeInitialization} / {@link #postProcessAfterInitialization}* would expose otherwise. Note that the object returned by this method will* be used as the bean reference unless the post-processor returns a different* wrapper from said post-process callbacks. In other words, those post-process* callbacks may either eventually expose the same reference or alternatively* return the raw bean instance from those subsequent callbacks (if the wrapper* for the affected bean has been built for a call to this method already,* it will be exposed as the final bean reference by default).* <p>The default implementation returns the given {@code bean} as-is.* @param bean the raw bean instance* @param beanName the name of the bean* @return the object to expose as the bean reference* (typically the passed-in bean instance as default)* @throws org.springframework.beans.BeansException in case of errors*/default Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {return bean;}}
實現類用途
AbstractAdvisingBeanPostProcessor用于 Spring AOP,提供通用的 Bean 后處理邏輯,支持自動代理和通知增強。
AbstractAdvisorAutoProxyCreator創建代理 Bean,并為其應用切面通知,用于自動代理。
AbstractAutoProxyCreator用于創建自動代理,增強 Bean。
AbstractBeanFactoryAwareAdvisingPostProcessor支持增強 Bean 的功能,并能在 Bean Factory 中獲得訪問。
AdvisorAdapterRegistrationManager用于注冊和管理 Spring AOP 中的 Advisor。
AnnotationAwareAspectJAutoProxyCreator結合 AspectJ 注解為 Bean 自動創建代理。
AspectJAwareAdvisorAutoProxyCreator專門為 Spring AOP 創建基于 AspectJ 的代理。
AsyncAnnotationBeanPostProcessor用于處理 @Async 注解,將異步任務執行功能應用到 Bean 中。
AutowiredAnnotationBeanPostProcessor處理 @Autowired 注解,自動注入依賴的 Bean。
BeanNameAutoProxyCreator通過 Bean 名稱創建代理 Bean,適用于特定名稱的 Bean。
BeanValidationPostProcessor自動觸發 Bean 的驗證,適用于 @Valid 注解的驗證。
CommonAnnotationBeanPostProcessor處理 Java EE 注解(如 @PostConstruct, @PreDestroy)的后處理。
DefaultAdvisorAutoProxyCreator默認的自動代理創建器,處理 AOP 中的 Advisor。
ImportAwareAotBeanPostProcessor用于處理 AOT(Ahead-of-Time)期間的導入依賴。
InfrastructureAdvisorAutoProxyCreator創建基礎設施相關的 Advisor 自動代理,通常用于系統級的 AOP 配置。
InitDestroyAnnotationBeanPostProcessor處理 @PostConstruct@PreDestroy 注解的 Bean 后處理器。
JmsListenerAnnotationBeanPostProcessor處理 @JmsListener 注解,將方法綁定為 JMS 消息監聽器。
LoadTimeWeaverAwareProcessor處理類加載時間增強,通常與字節碼增強技術(如 AspectJ)配合使用。
MethodValidationPostProcessor用于處理方法級驗證的 Bean 后處理器。
PersistenceAnnotationBeanPostProcessor處理持久化相關注解(如 @Transactional),自動配置事務管理。
PersistenceExceptionTranslationPostProcessor處理持久化異常的翻譯,將數據庫異常轉換為 Spring 的數據訪問異常。
ScheduledAnnotationBeanPostProcessor處理 @Scheduled 注解,自動配置定時任務。
ScriptFactoryPostProcessor處理腳本相關的配置,通常用于與腳本引擎相關的 Bean 配置。
ServletContextAwareProcessor使 Bean 能訪問 ServletContext,用于 Web 環境的上下文訪問。
SimpleServletPostProcessor簡單的 Servlet 后處理器,用于處理 Servlet 配置。

SmartInitializingSingleton

SmartInitializingSingleton 接口提供了一個 afterSingletonsInstantiated 方法,該方法在所有普通單例 bean 實例化完成后被調用,適用于在容器啟動過程中需要確保所有單例已創建的場景。

public interface SmartInitializingSingleton {/*** Invoked right at the end of the singleton pre-instantiation phase,* with a guarantee that all regular singleton beans have been created* already. {@link ListableBeanFactory#getBeansOfType} calls within* this method won't trigger accidental side effects during bootstrap.* <p><b>NOTE:</b> This callback won't be triggered for singleton beans* lazily initialized on demand after {@link BeanFactory} bootstrap,* and not for any other bean scope either. Carefully use it for beans* with the intended bootstrap semantics only.*/void afterSingletonsInstantiated();}

InitializingBean

InitializingBean 接口提供了一個 afterPropertiesSet 方法,在所有 bean 屬性設置完成后由容器調用,允許 bean 進行驗證和最終初始化。

public interface InitializingBean {/*** Invoked by the containing {@code BeanFactory} after it has set all bean properties* and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc.* <p>This method allows the bean instance to perform validation of its overall* configuration and final initialization when all bean properties have been set.* @throws Exception in the event of misconfiguration (such as failure to set an* essential property) or if initialization fails for any other reason*/void afterPropertiesSet() throws Exception;}

DisposableBean

DisposableBean 接口提供了一個 destroy 方法,在容器銷毀 bean 時調用,允許 bean 釋放資源并進行清理。

public interface DisposableBean {/*** Invoked by the containing {@code BeanFactory} on destruction of a bean.* @throws Exception in case of shutdown errors. Exceptions will get logged* but not rethrown to allow other beans to release their resources as well.*/void destroy() throws Exception;}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/89460.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/89460.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/89460.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

MISRA C-2012準則之聲明與定義

目錄 一、MISRA C簡介 二、聲明與定義 1. 必需。類型應被顯式聲明。 2. 必需。函數應以原型形式命名參數。 3. 必需。所有對象和函數的聲明需要使用完全相同的名字和參數。 4. 必需。當定義有外部鏈接的對象或函數時&#xff0c;兼容聲明應是可見的。 5. 必需。外部變量…

【blender】使用Vscode進行blender調試

配置vscodeblender 直接使用blender中的text editor沒有代碼補全&#xff0c;終端輸出通常和blender不在同一個頁面&#xff0c;只適合非常簡單的代碼測試。使用Vscode能有效提高blender調試的效率&#xff0c;具體方式見&#xff1a;VSCode 開發 Blender腳本工具配置。 調試…

Au速成班-樂理知識補充+網頁下載音樂

音質分類 通過查看音頻頻譜&#xff0c;128Kbps、192Kbps、320Kbps、無損&#xff08;Lossless HD&#xff09;CD音質&#xff08;頻率都在20kHz以上&#xff09;。 各家平臺對無損的定義不一樣&#xff0c;em各有說法吧。 無損的含義是&#xff1a;無損失的聲音格式。只要能…

JAVA中的Collection集合及ArrayList,LinkedLIst,HashSet,TreeSet和其它實現類的常用方法

文章目錄前言一、Collection 接口常用方法1.boolean add(E e)2.boolean remove(Object o)3.boolean contains(Object o)4.boolean isEmpty()5.int size()6.void clear()7.Object[] toArray()8.boolean containsAll(Collection<?> c)9.boolean addAll(Collection<? e…

有n棍棍子,棍子i的長度為ai,想要從中選出3根棍子組成周長盡可能長的三角形。請輸出最大的周長,若無法組成三角形則輸出0。

題目描述&#xff1a; 有n棍棍子&#xff0c;棍子i的長度為ai&#xff0c;想要從中選出3根棍子組成周長盡可能長的三角形。請輸出最大的周長&#xff0c;若無法組成三角形則輸出0。 算法為O(nlogn) 初始理解題目 首先&#xff0c;我們需要清楚地理解題目要求&#xff1a; 輸入…

【Echarts】 電影票房匯總實時數據橫向柱狀圖比圖

效果圖code <!DOCTYPE html> <html> <head><meta charset"utf-8"><title>圓角柱狀圖</title><script src"https://cdn.jsdelivr.net/npm/echarts5.4.3/dist/echarts.min.js"></script> </head> <…

【深度學習基礎】PyTorch中model.eval()與with torch.no_grad()以及detach的區別與聯系?

目錄1. 核心功能對比2. 使用場景對比3. 區別與聯系4. 典型代碼示例(1) 模型評估階段(2) GAN 訓練中的判別器更新(3) 提取中間特征5. 關鍵區別總結6. 常見問題與解決方案(1) 問題&#xff1a;推理階段顯存爆掉(2) 問題&#xff1a;Dropout/BatchNorm 行為異常(3) 問題&#xff1…

博客摘錄「 華為云平臺-FusionSphere OpenStack 8.2.1 系統加固」2025年7月15日

編號 加固項 "風險 等級" 加固原理/Rationale 審計方法/Audit 期望結果/Expect Results 加固方法/Remediation 1 OpenSSH加固配置 1.1 OpenSSH加固配置 1.1.1 SSH使用的版本 H "Op…

永磁同步電機MTPA與MTPV曲線具體仿真實現

永磁同步電機MTPA與MTPV曲線具體仿真實現 近期做了一些標定試驗&#xff0c;實際電機參數并不是確定的&#xff0c;而是變化的&#xff0c;因此很難通過解析的方法算出MTPA的對應點&#xff0c;以及在弱磁區如何過度到MTPV。這個在實際情況下都是一點點標出來的&#xff0c;我這…

Adobe Acrobat 插件功能、應用與開發

什么是 Acrobat 插件&#xff1f; Adobe Acrobat 插件是一種能夠擴展 Adobe Acrobat 閱讀器/查看器功能的軟件組件。Acrobat 是用于查看、創建和編輯 PDF 文檔的流行程序&#xff0c;而插件可以為其添加新功能&#xff0c;例如&#xff1a; #mermaid-svg-iqdM1wLkFQhd3ilQ {fon…

Redis學習系列之——高并發應用的緩存問題(二)

一、布隆過濾器布隆過濾器由一個 BitMap 和若干 Hash 函數組成&#xff0c;可以用來快速判斷一個值是否存在后端存儲中。它是解決 Redis 緩存穿透問題的一個不錯的解決方案。工作原理步驟1&#xff1a;當 key-value 鍵值對存儲到 Redis 后&#xff0c;向布隆過濾器添加 key步驟…

Expression 類的靜態方法

public static MethodCallExpression Call(Type type, // 包含目標方法的類型string methodName, // 方法名稱Type[]? typeArguments, // 泛型方法的類型參數&#xff08;非泛型方法為 null&#xff09;params Expression[]? arguments // 方…

[Nagios Core] 事件調度 | 檢查執行 | 插件與進程

第五章&#xff1a;事件調度 歡迎回到Nagios Core&#xff01; 在上一章第四章&#xff1a;配置加載中&#xff0c;我們了解了Nagios如何讀取配置文件以知曉需要監控的對象&#xff0c;比如我們的朋友"Web Server 1"。此時Nagios內存中已構建完整的基礎設施拓撲圖。…

Web3 常用前端庫介紹

一、Web3 前端開發&#xff1a;連接用戶與區塊鏈的橋梁 隨著 Web3 生態的蓬勃發展&#xff0c;前端開發從傳統的頁面渲染進化為區塊鏈交互的核心樞紐。Web3 前端庫作為連接用戶與區塊鏈的橋梁&#xff0c;承擔著錢包集成、合約交互、數據可視化等關鍵功能。本文將系統解析主流 …

cnpm命令報internal/modules/cjs/loader.js:797 throw err; ^ Error: Cannot find

在運行一個項目的時候&#xff0c;需要升級電腦各組件的版本&#xff0c;結果導致cnpm命令無法正常使用&#xff0c;cnpm任何命令都會報如下這個錯&#xff1a;找了半天&#xff0c;發現是由于cnpm與npm的版本不一致導致的&#xff0c;所以需要卸載并重新安裝cnpm&#xff0c;重…

15、鴻蒙Harmony Next開發:創建自定義組件

目錄 自定義組件的基本用法 自定義組件的基本結構 struct Component freezeWhenInactive build()函數 Entry EntryOptions Reusable 成員函數/變量 自定義組件的參數規定 build()函數 自定義組件生命周期 自定義組件的創建和渲染流程 自定義組件重新渲染 自定義…

深入理解Map.Entry.comparingByValue()和Map.Entry.comparingByKey()

文章目錄深入理解Map.Entry.comparingByValue()和Map.Entry.comparingByKey()1. 方法定義comparingByKey()comparingByValue()2. 基本用法2.1 使用comparingByKey()2.2 使用comparingByValue()3. 方法重載版本comparingByKey(Comparator)comparingByValue(Comparator)4. 高級用…

Mac下載mysql

安裝 brew list --versions | grep mysql查看已安裝的mysql版本brew search mysql查看支持的mysql版本brew info mysql查看mysql版本信息brew install mysql進行安裝/opt/homebrew/opt/mysql/bin/mysqld --initialize-insecure --user$(whoami) --basedir$(brew --prefix mysql…

PageHelper使用說明文檔

文章目錄一、簡介二、集成步驟三、使用方法四、注意事項五、高級用法一、簡介 PageHelper 是一個開源的 MyBatis 分頁插件&#xff0c;它可以幫助我們在使用 MyBatis 進行數據庫操作時方便地實現分頁功能。通過簡單的配置和少量的代碼修改&#xff0c;就可以在查詢數據時實現分…

grpo nl2sql qwen3 模型強化學習訓練有效果的成立條件有哪些

在使用GRPO&#xff08;強化學習算法&#xff09;對Qwen3模型在NL2SQL&#xff08;自然語言到SQL轉換&#xff09;任務上進行強化學習&#xff08;RL&#xff09;訓練時&#xff0c;其效果成立的核心條件可歸納為以下幾個關鍵維度&#xff0c;這些條件相互關聯&#xff0c;共同…