<select id="queryTomId" parameterType="java.lang.String" resultType="java.lang.String">
select
TOM_ID
from
TOM_SERVER_CFG
where 1=1
<if test="ipAddr!= null and ipAddr!= ''">
AND HOST_IP = #{ipAddr}
</if>
</select>
输出日志:
11:04:02.942 [http-bio-8080-exec-5] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession
11:04:02.942 [http-bio-8080-exec-5] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7ecc30a4] was not registered for synchronization because synchronization is not active
11:04:02.942 [http-bio-8080-exec-5] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7ecc30a4]
程序就卡在这,也没有返回
不知道你怎么配置的,可以看一下这个http://www.mamicode.com/info-detail-204849.html
可能是因为在查询的时候,因为缓存中存在数据,所以直接从缓存中去获取数据,并没有从数据库里面查询,在mybatis里面加上useCache="false"看看这句话表示不走缓存