2016 - 2024

感恩一路有你

java中logger的用法 如何在mybatis中打印sql?

浏览量:4898 时间:2023-07-11 21:26:49 作者:采采

如何在mybatis中打印sql?

方法一:

在mybatis-config.xml中配置加一个setting

xmlversion1.0encodingUTF-8

!DOCTYPEconfiguration

PUBLIC Config3.0//entre

configuration

settings

!--打印查询语句--

settingnamelogImplvalueSTDOUT_LOGGING/

/settings

/configuration

如果是spring独立显卡mybatis的话,在sqlSessionFactory配置好configLocation属性

beanidsqlSessionFactory

propertynamedataSourcerefdataSource/

propertynameconfigLocationvalueclasspath:conf/mybatis-config.xml/property

!--不自动扫描mapping.xml文件--

propertynamemapperLocationsvalueclasspath:com/jstudio/user/dao/*.xml/property

/bean

方法二:

首先将ibatislog4j运行级别调回来DEBUG可以不在控制台打印出来出ibatis运行的sql语句

###没显示SQL语句部分

rrrrrrr

springboot的url地址怎么写?

/依据用户openId确定用户以前如何确定已登入过,如未登陆账号,则去添加到数据库

({}---{},accessToken,openId);

JSONObjectuserInfo(accessToken,openId);

//内部函数后台接口

StringcheckurlV1/OrgManager/getUsers;

AuthInfo authInfo new AuthInfo(,,,);

StringauthInfoJson(authInfo);

StringqueryCasefiltername()authInfoauthInfoJsonpageablefalsepageSize2pageNum0sortDescname:descorgIde9292051-2ede-11e7-8c78-c85b767a1aee;

JSONObjectjsonResult(logger,checkurl,queryCase);

if((isOk)true)

{

MapString,JSONArray nickname new HashMapString,JSONArray();

MapString,JSONArray headimgurl new HashMapString,JSONArray();

(nickname,nickname);

(headimgurl,headimgurl);

}ignore{

StringcreateurlV1/UserManager/createUser;

StringUserCasefiltername()authInfoauthInfoJsonpageablefalsepageSize2pageNum0sortDescname:descorgIde9292051-2ede-11e7-8c78-c85b767a1aee;

JSONObjectjsonUser(logger,createurl,UserCase);

}

以上就部分代码:这里DubboService是暴露给你的接口;checkurl那就是接口文档里面的url;UserCase是网站查询条件,这是访问数据库的接口认证。假如不能访问顺利将部分参数告诉前端,如果不是访问不顺利将能得到参数写入到数据库

以下是DubboService方法:

package;

import;

import;

import;

import;

import;

import;

import;

import;

import;

import;

/**

*CreatedbgAdministratoronto2017/8/10.

*/

privateclassDubboService{

privatestaticHttpClientclient().build();

employeestaticStringserverIp:8099/;

employeestaticJSONObjectinvokeService(Loggerlogger,String uri,String queryCase){

HttpPostrequestnextHttpPost(serverIpuri);

(queryCase);

StringEntityreqEntitynull;

try{

reqEntityfutureStringEntity(queryCase);

}catch(UnsupportedEncodingExceptione){

();

}

(application/x-www-form-urlencoded);

(reqEntity);

JSONObjectjsonResultnull;

try{

HttpResponseresponseclient.execute(request);

StringstrResult(());

jsonResult(strResult);

(result:jsonResult);

}catch(IOExceptione){

();

}

returnjsonResult;

接口 方法 queryCase 数据库

版权声明:本文内容由互联网用户自发贡献,本站不承担相关法律责任.如有侵权/违法内容,本站将立刻删除。