com.xunmo.XmFlywayPluginImp Maven / Gradle / Ivy
package com.xunmo;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.noear.solon.Solon;
import org.noear.solon.core.AopContext;
import org.noear.solon.core.Plugin;
import org.noear.solon.core.Props;
import javax.sql.DataSource;
import java.util.Map;
import java.util.Properties;
@Slf4j
public class XmFlywayPluginImp implements Plugin {
@Override
public void start(AopContext context) {
final Props props = context.cfg();
props.loadAddIfAbsent(XmPackageNameConstants.XM_FLYWAY + ".yml");
// final SolonApp app = Solon.app();
context.subWrapsOfType(DataSource.class, bw -> {
final String named = bw.name();
log.info("{} 异步订阅 DataSource({}), 执行 flyway 动作", XmPackageNameConstants.XM_FLYWAY, named);
final String keyStarts = "flyway." + named;
final boolean isEnabled = props.getBool(keyStarts + ".enable", true);
if (isEnabled) {
ThreadUtil.execute(() -> {
final Properties properties = new Properties();
final Props flayWayProps = Solon.cfg().getProp(keyStarts);
for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy