Skip to content

Commit 056eb8a

Browse files
committed
feat(schedule): 新增 ConditionalOnEnabledScheduleJob 注解
1 parent e099b5e commit 056eb8a

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package top.continew.admin.schedule.annotation;
18+
19+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
20+
import top.continew.starter.core.constant.PropertiesConstants;
21+
22+
import java.lang.annotation.*;
23+
24+
/**
25+
* 是否启用 Snail Job 注解
26+
*
27+
* @author Charles7c
28+
* @since 2025/5/18 12:03
29+
*/
30+
@Retention(RetentionPolicy.RUNTIME)
31+
@Target({ElementType.TYPE, ElementType.METHOD})
32+
@Documented
33+
@ConditionalOnProperty(prefix = "snail-job", name = PropertiesConstants.ENABLED, havingValue = "true", matchIfMissing = true)
34+
public @interface ConditionalOnEnabledScheduleJob {
35+
}

continew-plugin/continew-plugin-schedule/src/main/java/top/continew/admin/schedule/config/SnailJobConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import com.aizuda.snailjob.client.common.event.SnailClientStartingEvent;
2424
import com.aizuda.snailjob.client.starter.EnableSnailJob;
2525
import org.slf4j.LoggerFactory;
26-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2726
import org.springframework.context.annotation.Configuration;
2827
import org.springframework.context.event.EventListener;
28+
import top.continew.admin.schedule.annotation.ConditionalOnEnabledScheduleJob;
2929

3030
/**
3131
* Snail Job 配置
@@ -35,7 +35,7 @@
3535
*/
3636
@Configuration
3737
@EnableSnailJob
38-
@ConditionalOnProperty(prefix = "snail-job", value = "enabled", havingValue = "true", matchIfMissing = true)
38+
@ConditionalOnEnabledScheduleJob
3939
public class SnailJobConfiguration {
4040

4141
/**

0 commit comments

Comments
 (0)