今天在学习 ssm整合项目配置文件遇到了两个简单的问题,但是不注意是很难发现的
- 数据源配置错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in URL [file:/E:/IDEA_code/mySSM/ssm/target/classes/spring.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.String' to required type 'java.sql.Driver' for property 'driver'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.sql.Driver' for property 'driver': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:602)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0 (AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons (DefaultListableBeanFactory.java:897)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization (AbstractApplicationContext.java:879)
at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:551)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext (ContextLoader.java:401)
at org.springframework.web.context.ContextLoader.initWebApplicationContext (ContextLoader.java:292)
at org.springframework.web.context.ContextLoaderListener.contextInitialized (ContextLoaderListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart (StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal (StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call (ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
at java.lang.Thread.run (Thread.java:745)
我们在单纯的配置mybatis引入数据源的时候是这样的:
但是在综合整合ssm时候是这样的:
驱动的名字不一样 导致数据源加载失败
- mapper映射文件没有扫描到 ,在pom.xml添加扫描注册文件
<!--插件的配置-->
<build>
<!--mapper映射文件,配置文件 等资源的扫描-->
<resources>
<resource>
<directory>src/main/resources</directory><!--所在的目录-->
<includes> <!--包括目录下的.property .xml文件都会扫描到-->
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<!--略-->
</build>