diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/WallConfigRegister.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/WallConfigRegister.java new file mode 100644 index 00000000..e165b59b --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/WallConfigRegister.java @@ -0,0 +1,47 @@ +package org.jeecg.config; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.SpringApplicationRunListener; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.MutablePropertySources; +import org.springframework.core.env.PropertySource; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author eightmonth@qq.com + * @date 2024/4/8 11:37 + */ +public class WallConfigRegister implements SpringApplicationRunListener { + + public SpringApplication application; + + private String[] args; + + + /** + * 必备,否则启动报错 + * @param application + * @param args + */ + public WallConfigRegister(SpringApplication application, String[] args) { + this.application = application; + this.args = args; + } + + @Override + public void contextLoaded(ConfigurableApplicationContext context) { + ConfigurableEnvironment env = context.getEnvironment(); + Map props = new HashMap<>(); + props.put("spring.datasource.dynamic.druid.wall.selectWhereAlwayTrueCheck", false); + + MutablePropertySources propertySources = env.getPropertySources(); + + PropertySource> propertySource = new MapPropertySource("jeecg-datasource-config", props); + + propertySources.addLast(propertySource); + } +} \ No newline at end of file diff --git a/jeecg-boot-base-core/src/main/resources/META-INF/spring.factories b/jeecg-boot-base-core/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..5f73e208 --- /dev/null +++ b/jeecg-boot-base-core/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.SpringApplicationRunListener=\ +org.jeecg.config.WallConfigRegister \ No newline at end of file