diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/annotation/ConditionalOnEnabledScheduleJob.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/annotation/ConditionalOnEnabledScheduleJob.java new file mode 100644 index 00000000..59d0e7a2 --- /dev/null +++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/annotation/ConditionalOnEnabledScheduleJob.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * 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. + */ + +package top.continew.admin.schedule.annotation; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import top.continew.starter.core.constant.PropertiesConstants; + +import java.lang.annotation.*; + +/** + * 是否启用 Snail Job 注解 + * + * @author Charles7c + * @since 2025/5/18 12:03 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD}) +@Documented +@ConditionalOnProperty(prefix = "snail-job", name = PropertiesConstants.ENABLED, havingValue = "true", matchIfMissing = true) +public @interface ConditionalOnEnabledScheduleJob { +} \ No newline at end of file diff --git a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/config/SnailJobConfiguration.java b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/config/SnailJobConfiguration.java index c9bc2083..193fa18c 100644 --- a/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/config/SnailJobConfiguration.java +++ b/continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/config/SnailJobConfiguration.java @@ -23,9 +23,9 @@ import com.aizuda.snailjob.client.common.appender.SnailLogbackAppender; import com.aizuda.snailjob.client.common.event.SnailClientStartingEvent; import com.aizuda.snailjob.client.starter.EnableSnailJob; import org.slf4j.LoggerFactory; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Configuration; import org.springframework.context.event.EventListener; +import top.continew.admin.schedule.annotation.ConditionalOnEnabledScheduleJob; /** * Snail Job 配置 @@ -35,7 +35,7 @@ import org.springframework.context.event.EventListener; */ @Configuration @EnableSnailJob -@ConditionalOnProperty(prefix = "snail-job", value = "enabled", havingValue = "true", matchIfMissing = true) +@ConditionalOnEnabledScheduleJob public class SnailJobConfiguration { /**