标签:3ds 绝对路径 ali strong local data config logs 文件的
本次全部学习内容:MyBatisLearning
jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3307/shopping jdbc.username=root jdbc.password=1234567
<!-- 加载属性文件 -->
<!-- properties -->
<properties resource="db.properties"></properties>
.......
<property name="driver" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
.......
<!-- 加载属性文件 -->
<!-- properties -->
<properties resource="db.properties">
<!-- 可以配置一些属性名和属性值 -->
<property name="jdbc.root" value="root"/>
</properties>
<!-- 别名 -->
<typeAliases>
<!-- 针对单个别名的定义 -->
<typeAlias type="com.MrChengs.po.User" alias="user"/>
</typeAliases>
<!-- 根据id查询 -->
<!-- public User findUserById(int id) throws Exception; -->
<select id="findUserById" parameterType="int" resultType="user">
select * from user where id=#{id}
</select>
<typeAliases>
<!-- 批量起别名 -->
<!-- 指定自动扫描的po类,自动定义 别名,别名就是类名(首字母大小写都可以)-->
<package name="com.MrChengs.po"/>
</typeAliases>
其余代码不变进行测试!!!
<select id="findUserById" parameterType="int" resultType="user"> select * from user where id = #{id} </select>
mybatis支持的:
<mappers>
<mapper resource="sqlmap/User.xml"/>
<mapper resource="mapper/UserMapper.xml"/>
</mappers>
<!-- 加载 映射文件 -->
<mappers>
<mapper resource="sqlmap/User.xml"/>
<!-- 通过mmapper接口加载映射文件 -->
<!-- 遵循规范:需要将mapper接口类和mapper.xml映射文件名保持一致,且在同一个目录 -->
<!-- 前提要使用mapper代理方法 -->
<mapper class="com.MrChengs.mapper.UserMapper"/>
</mappers>

此时是可以测试成功的
<mappers>
<mapper resource="sqlmap/User.xml"/>
<!-- 批量加载 -->
<!-- 指定mapper接口的包名,自动扫描包下的 -->
<!-- 遵循规范:需要将mapper接口类和mapper.xml映射文件名保持一致,且在同一个目录 -->
<!-- 前提要使用mapper代理方法 -->
<!-- 推荐使用 -->
<package name="com.MrChengs.mapper"/>
</mappers>
此时是可以测试成功的
标签:3ds 绝对路径 ali strong local data config logs 文件的
原文地址:https://www.cnblogs.com/Mrchengs/p/9756422.html