@SpringBoot+MyBatis
SpringBoot+MyBatis遇到的问题处理
作为一位Java小白,之前使用原生MySQL的方式实现了一个简单的Spring web项目,但是呢,听大佬说,现在原生的很少用,大多使用的是Mybatis,所以就换成了Mybatis实现,这个过程中的踩了很多坑,感觉很有意思,记录一下
1.为啥要使用MyBatis而不用原生Mysql
我们可以首先来看看这两张图
从这两张图片我们可以清楚的知道为啥需要使用MyBatis,以及使用MyBatis涉及到的一些配置。当然至于为什么要进行这样配置,我目前没有搞清楚,后续弄清楚了会发布出来滴,😜
2. 错误一:通配符的匹配很全面, 但无法找到元素 ‘context:property-placeholder’ 的声明。
- 我们首先定位到这个报错所在的文件applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
">
<!-- 与PooledDataSource集成(二选一)-->
<!-- <bean id="dataSource" class="org.apache.ibatis.datasource.pooled.PooledDataSource">-->
<!-- <property name="driver" value="${jdbc.driver}"/>-->
<!-- <property name="url" value="${jdbc.url}"