调整 sql 日志打印

This commit is contained in:
卢春梦 2025-01-02 12:48:23 +08:00
parent 2980a70968
commit e584cfae49
4 changed files with 9 additions and 45 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -37,4 +37,9 @@ public class MybatisPlusProperties {
*/
protected Boolean overflow = false;
/**
* 是否打印 sql
*/
private boolean sqlLog = true;
}