标签:集成 debug model .class color com run use bat
一、SpringBoot常见配置
(1)SpingBoot与MyBatis集成时跟踪SQL语句
log4j:
logger:
java:
sql:
ResultSet: TRACE
(2)日志跟踪
debug: true logging: config: classpath:log4j2/log4j2.xml
(3)MyBatis集成:
#mybatis配置
mybatis:
#配置映射类所在包名
type-aliases-package: com.xx.it.model
(数据库实体对象所在路径,一般为@Data对象,非Mapper注释项所在路径)
#配置mapper.xml文件所在路径
mapper-location: classpath:com/xx/it/*.xml(非必须项,可以不配)
#不需要再配置Spring任何文件
@SpringBootApplication
public class Application {
SpringApplication.run(Application.class,args);
}
Mapper所在路径不需要配置,系统会自动扫描与Application同级及以下的所有目录,同时对应的Spring也不需要配置
二、常见错误
(1)SpringBoot与MyBatis集成
A.ResultMap与ResultType导致的问题
<resultMap id="sample" type="com.xx.it.SampleVo">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="useYn" column="use_yn" />
</resultMap>
<select id="selectSample" resultMap="sample">
select id,name,useYn from sample where id = #{id}
</select>
<select id="getReply" parameterType="sampleVo" resultType="sample">
select id,name,useYn from sample where id = #{id}
</select>
ResultMap:组装数据库中结果与实体对象的映射关系(将数据库中查询出来的结果映射给实体类)
column:表中字段名;property:实体类的属性名
标签:集成 debug model .class color com run use bat
原文地址:http://www.cnblogs.com/moonandstar08/p/7599248.html