mirror of
https://github.com/chillzhuang/blade-tool
synced 2025-01-09 22:45:46 +08:00
✨ 调整 sql 日志打印
This commit is contained in:
parent
2980a70968
commit
e584cfae49
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springblade.core.mp.config;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* druid 连接池配置
|
||||
*
|
||||
* @author L.cm
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ConfigurationProperties("blade.mybatis-plus")
|
||||
public class BladeMybatisPlusProperties {
|
||||
|
||||
/**
|
||||
* 是否打印 sql
|
||||
*/
|
||||
private boolean sqlLog = true;
|
||||
|
||||
}
|
@ -46,10 +46,7 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
@AutoConfiguration
|
||||
@AllArgsConstructor
|
||||
@MapperScan("org.springblade.**.mapper.**")
|
||||
@EnableConfigurationProperties({
|
||||
MybatisPlusProperties.class,
|
||||
BladeMybatisPlusProperties.class
|
||||
})
|
||||
@EnableConfigurationProperties(MybatisPlusProperties.class)
|
||||
public class MybatisPlusConfiguration {
|
||||
|
||||
|
||||
@ -104,7 +101,7 @@ public class MybatisPlusConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "blade.mybatis-plus.sql-log", matchIfMissing = true)
|
||||
public SqlLogFilter sqlLogFilter(BladeMybatisPlusProperties properties) {
|
||||
public SqlLogFilter sqlLogFilter(MybatisPlusProperties properties) {
|
||||
return new SqlLogFilter(properties);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.mp.config.BladeMybatisPlusProperties;
|
||||
import org.springblade.core.mp.props.MybatisPlusProperties;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
|
||||
import java.sql.SQLException;
|
||||
@ -47,7 +47,7 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class SqlLogFilter extends FilterEventAdapter {
|
||||
private static final SQLUtils.FormatOption FORMAT_OPTION = new SQLUtils.FormatOption(false, false);
|
||||
private final BladeMybatisPlusProperties properties;
|
||||
private final MybatisPlusProperties properties;
|
||||
|
||||
@Override
|
||||
protected void statementExecuteBefore(StatementProxy statement, String sql) {
|
||||
|
@ -37,4 +37,9 @@ public class MybatisPlusProperties {
|
||||
*/
|
||||
protected Boolean overflow = false;
|
||||
|
||||
/**
|
||||
* 是否打印 sql
|
||||
*/
|
||||
private boolean sqlLog = true;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user