代码拉取完成,页面将自动刷新
同步操作将从 dromara/disjob 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/* __________ _____ *\
** \______ \____ _____/ ____\____ ____ Copyright (c) 2017-2023 Ponfee **
** | ___/ _ \ / \ __\/ __ \_/ __ \ http://www.ponfee.cn **
** | | ( <_> ) | \ | \ ___/\ ___/ Apache License Version 2.0 **
** |____| \____/|___| /__| \___ >\___ > http://www.apache.org/licenses/ **
** \/ \/ \/ **
\* */
package cn.ponfee.disjob.admin;
import cn.ponfee.disjob.common.base.IdGenerator;
import cn.ponfee.disjob.common.base.Symbol.Char;
import cn.ponfee.disjob.common.spring.EnableJacksonDateConfigurer;
import cn.ponfee.disjob.core.base.JobConstants;
import cn.ponfee.disjob.core.util.JobUtils;
import cn.ponfee.disjob.id.snowflake.db.DbDistributedSnowflake;
import cn.ponfee.disjob.supervisor.configuration.EnableSupervisor;
import cn.ponfee.disjob.worker.configuration.EnableWorker;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import static cn.ponfee.disjob.supervisor.dao.SupervisorDataSourceConfig.JDBC_TEMPLATE_SPRING_BEAN_NAME;
/**
* Disjob admin configuration
*
* @author Ponfee
*/
@Configuration
@ComponentScan("cn.ponfee.disjob.test.handler")
@EnableJacksonDateConfigurer // 解决日期反序列化报错的问题
@EnableSupervisor // disjob-admin必须启用Supervisor角色,即:必须加@EnableSupervisor注解
@EnableWorker // 若要取消worker角色可去掉@EnableWorker注解
public class DisjobAdminConfiguration implements WebMvcConfigurer {
public DisjobAdminConfiguration(@Nullable ObjectMapper mapper) {
if (mapper == null) {
throw new Error("Not found jackson object mapper in spring container.");
}
SimpleModule simpleModule = new SimpleModule();
// Long 转为 String 防止 js 丢失精度
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
mapper.registerModule(simpleModule);
}
@Bean
public IdGenerator idGenerator(@Qualifier(JDBC_TEMPLATE_SPRING_BEAN_NAME) JdbcTemplate jdbcTemplate,
@Value("${" + JobConstants.SPRING_WEB_SERVER_PORT + "}") int port,
@Value("${" + JobConstants.DISJOB_BOUND_SERVER_HOST + ":}") String boundHost) {
return new DbDistributedSnowflake(jdbcTemplate, JobConstants.DISJOB_KEY_PREFIX, JobUtils.getLocalHost(boundHost) + Char.COLON + port);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。