-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6007 from EightMonth/master
修复 #5901
- Loading branch information
Showing
5 changed files
with
83 additions
and
28 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
jeecg-boot-base-core/src/main/java/org/jeecg/config/DruidWallConfigRegister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 [email protected] | ||
* @date 2024/4/8 11:37 | ||
*/ | ||
public class DruidWallConfigRegister implements SpringApplicationRunListener { | ||
|
||
public SpringApplication application; | ||
|
||
private String[] args; | ||
|
||
|
||
/** | ||
* 必备,否则启动报错 | ||
* @param application | ||
* @param args | ||
*/ | ||
public DruidWallConfigRegister(SpringApplication application, String[] args) { | ||
this.application = application; | ||
this.args = args; | ||
} | ||
|
||
@Override | ||
public void contextLoaded(ConfigurableApplicationContext context) { | ||
ConfigurableEnvironment env = context.getEnvironment(); | ||
Map<String, Object> props = new HashMap<>(); | ||
props.put("spring.datasource.dynamic.druid.wall.selectWhereAlwayTrueCheck", false); | ||
|
||
MutablePropertySources propertySources = env.getPropertySources(); | ||
|
||
PropertySource<Map<String, Object>> propertySource = new MapPropertySource("jeecg-datasource-config", props); | ||
|
||
propertySources.addLast(propertySource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
jeecg-boot-base-core/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.springframework.boot.SpringApplicationRunListener=\ | ||
org.jeecg.config.DruidWallConfigRegister |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -565,4 +565,4 @@ | |
</modules> | ||
</profile> | ||
</profiles> | ||
</project> | ||
</project> |