- spring: 新增 @FastServiceScan 扫描注解与 FastServiceScanRegistrar / FastServiceScannerProcessor,支持扫描 FastBaseIService 和 FastBaseIServiceNew3518 两个基类、value/basePackages 别名、缺失基类跳过 - spring: ApplicationDestroyedRunner / ApplicationReadyEventListener / ApplicationStartedRunner / ContextClosedEventListener 迁移为 Kotlin,弃用注解补全 @Deprecated + ReplaceWith - build: 新增 VERSIONSTYPE 控制 RELEASES/SNAPSHOT 版本后缀,补充 Spring / MyBatis-Plus 测试依赖 - test: 新增 FastServiceScanRegistrarTest 5 个用例与 FastServiceScannerProcessorTest 2 个用例
This commit is contained in:
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2026 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile ApplicationDestroyedRunner.kt
|
||||
* LastUpdate 2026-11-23 15:07:06
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.springboot.annotation
|
||||
|
||||
import org.springframework.context.event.ContextClosedEvent
|
||||
import org.springframework.context.event.EventListener
|
||||
import org.springframework.core.Ordered
|
||||
import org.springframework.core.annotation.AliasFor
|
||||
import org.springframework.core.annotation.Order
|
||||
|
||||
/**
|
||||
* 应用销毁(上下文关闭)事件监听注解。
|
||||
*
|
||||
* 标注在 Spring Bean 的方法上,当 Spring 应用上下文关闭
|
||||
* ([ContextClosedEvent] 发布)时自动调用该方法。
|
||||
*
|
||||
* 已弃用,请改用 [ContextClosedEventListener](监听相同事件,命名更规范)。
|
||||
*
|
||||
* @see ContextClosedEventListener
|
||||
* @see EventListener
|
||||
* @see ContextClosedEvent
|
||||
*/
|
||||
@Deprecated(
|
||||
message = "已弃用,请改用 ContextClosedEventListener(监听相同事件,命名更规范)",
|
||||
replaceWith = ReplaceWith(
|
||||
expression = "ContextClosedEventListener",
|
||||
imports = ["com.mingliqiye.utils.springboot.annotation.ContextClosedEventListener"],
|
||||
),
|
||||
)
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.ANNOTATION_CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@MustBeDocumented
|
||||
@EventListener(ContextClosedEvent::class)
|
||||
@Order
|
||||
annotation class ApplicationDestroyedRunner(
|
||||
/**
|
||||
* SpEL 条件表达式,仅当表达式求值为 true 时才执行监听方法。
|
||||
*
|
||||
* 默认为空字符串,表示无条件执行。
|
||||
*/
|
||||
@get:AliasFor(annotation = EventListener::class, attribute = "condition")
|
||||
val condition: String = "",
|
||||
|
||||
/**
|
||||
* 当事件不是 [ContextClosedEvent] 类型时是否仍默认执行监听方法。
|
||||
*
|
||||
* 默认为 `true`。
|
||||
*/
|
||||
@get:AliasFor(annotation = EventListener::class, attribute = "defaultExecution")
|
||||
val defaultExecution: Boolean = true,
|
||||
|
||||
/**
|
||||
* 监听器的唯一标识,用于注册可指定 id 的监听器。
|
||||
*
|
||||
* 默认为空字符串,表示自动生成。
|
||||
*/
|
||||
@get:AliasFor(annotation = EventListener::class, attribute = "id")
|
||||
val id: String = "",
|
||||
|
||||
/**
|
||||
* 监听器的执行顺序,值越小优先级越高。
|
||||
*
|
||||
* 默认为 [Ordered.LOWEST_PRECEDENCE]。
|
||||
*/
|
||||
@get:AliasFor(annotation = Order::class, attribute = "value")
|
||||
val order: Int = Ordered.LOWEST_PRECEDENCE,
|
||||
)
|
||||
Reference in New Issue
Block a user