spring boot和mybatis整合项目,测试的时候出现这个错误,哪位大神知道怎么解决 5C

在持久层测试运行的时候出现以下错误,一直找不出什么原因


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138) [spring-boot-test-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [spring-test-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) [.cp/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    ... 42 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
    at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:224) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:176) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:43) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:81) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_171]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_171]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    ... 43 common frames omitted

10个回答

很明显是这个错误:Cannot load driver class: com.mysql.jdbc.Driver。检查你的依赖包仓库,是否存在这个。如果不存在,是否依赖配置有问题。

sl20120327
Toria2015 回复fengyidong123: 麻烦确认解决一下。5C才能到账。
一年多之前 回复
sl20120327
Toria2015 回复fengyidong123: 当然要根据你的工程相关其他支持jar包的版本选择对应的版本jar包
一年多之前 回复
sl20120327
Toria2015 回复fengyidong123: <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>6.0.3</version> </dependency>
一年多之前 回复
fengyidong123
fengyidong123 是缺少哪个jar包
一年多之前 回复

Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is javax.naming.NoInitialContextException:

此错误是在测试类里测试applicationContext.xml文件是否有错的时候在控制台报的错。代码本身是没有问题的,意思是少了一个包。

解决方法:

将commons-pool.jar此包拷贝到lib下,就Ok了

jar包问题试试吧

刚才答案片面了, Cannot load driver class: com.mysql.jdbc.Driver 这是问题,楼上解答了

以前也遇到过类似问题,如果配置文件没有错,那就是依赖包的问题,当时是用得maven导包,有可能是导得包是坏得,用Java反编译查看不了,那就是坏的。
maven会把加载的包的依赖包也一起加载(如果你是用maven导包的话),有时版本不匹配,这个最头疼,那就得找匹配的版本。

你们的答案都不对,是配置文件出问题了,我自己已经搞定了,谢谢

xml 配置文件有问题吧 你仔细找找。
org.springframework.beans.factory。BeanCreationException:创建bean与错误的名字“数据源”中定义的类路径资源“光之轮”[org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration $。类:通过工厂方法Bean实例化失败;嵌套的异常org.springframework.beans。BeanInstantiationException:未能实例化[com.zaxxer.hikari。(HikariDataSource):工厂方法'dataSource'抛出异常;嵌套的异常. lang。IllegalStateException:不能装入驱动程序类:com.mysql.jdbc.Driver。


mysql
mysql-connector-java

是否有引入Mysql的驱动包依赖,

xml配置中DataSourceConfiguration 的配置方法错了,可以看下这个DataSourceConfiguration的配置方法。

正常的HikariDataSource 需要配置到sqlFactory中

https://blog.csdn.net/yangcaogongcun/article/details/50781223 看其中的applicationContext-mybatis.xml 的配置

创建数据源的时候出现异常
Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver
大概的意思就是找不到驱动文件类
因为不是找不到文件class,像上述的情况,一般是因为你的驱动mysql.xxxx.jar版本太低了,而你的spring版本比较高造成的,可以替换成最新版本的驱动

检查mysql的jar包是否已导入

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
spring 与mybatis 整合出现错误
一月 16, 2017 10:57:49 上午 org.apache.catalina.core.StandardContext listenerStartrn严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerrnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [config/spring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [org.springframework.core.io.Resource[]] for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:fjnu/mapper/*.xml]: class path resource [fjnu/mapper/] cannot be resolved to URL because it does not existrn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:732)rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)rn at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)rn at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)rn at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)rn at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)rn at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)rn at java.util.concurrent.FutureTask.run(Unknown Source)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)rn at java.lang.Thread.run(Unknown Source)rnCaused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [org.springframework.core.io.Resource[]] for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:fjnu/mapper/*.xml]: class path resource [fjnu/mapper/] cannot be resolved to URL because it does not existrn at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:596)rn at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:603)rn at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:216)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1532)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1491)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1231)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)rn ... 20 morernCaused by: java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:fjnu/mapper/*.xml]: class path resource [fjnu/mapper/] cannot be resolved to URL because it does not existrn at org.springframework.core.io.support.ResourceArrayPropertyEditor.setAsText(ResourceArrayPropertyEditor.java:116)rn at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:468)rn at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:441)rn at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:199)rn at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:576)rn ... 26 morernrn一月 16, 2017 10:57:49 上午 org.apache.catalina.core.StandardContext startInternalrn严重: One or more listeners failed to start. Full details will be found in the appropriate container log filern一月 16, 2017 10:57:49 上午 org.apache.catalina.core.StandardContext startInternalrn严重: Context [] startup failed due to previous errorsrn一月 16, 2017 10:57:49 上午 org.apache.catalina.core.ApplicationContext logrn信息: Closing Spring root WebApplicationContextrn一月 16, 2017 10:57:49 上午 org.apache.coyote.AbstractProtocol startrn信息: Starting ProtocolHandler ["http-nio-8080"]rn一月 16, 2017 10:57:49 上午 org.apache.coyote.AbstractProtocol startrn信息: Starting ProtocolHandler ["ajp-nio-8009"]rn一月 16, 2017 10:57:49 上午 org.apache.catalina.startup.Catalina startrn信息: Server startup in 5746 msrn各位大神帮忙看看
Spring Boot整合Mybatis
Spring Boot整合MyBatis实现Restfull API实例,具体原理请参考笔者专栏Spring Boot从入门到精通
spring boot整合mybatis
本项目使用的环境: 开发工具:myeclipse springboot: 1.5.6 jdk:1.7 maven:3.3.9
Spring Boot整合MyBatis(下)
<p>rn <span style="color:#000000;font-size:16px;">本套课程由CSDN学院与咕泡学院共同打造,主要会围绕</span><span style="color:#000000;font-size:16px;">Spring Boot初遇、基本常识、注解和源码分析以及进阶4个方面进行讲解。</span> rn</p>rn<p>rn <span style="color:#000000;font-size:14px;"><br />rn</span> rn</p>rn<p>rn <span style="color:#000000;font-size:16px;">即使你之前从来没有用过Spring Boot也没关系,课程会带领你从0到进阶一步步提升,让你对Spring Boot爱不释手,同时了解Spring Boot的原理和源码。</span> rn</p>
spring boot之整合mybatis
spring boot与mybatis的完美整合(源码)!!!
spring boot和mybatis整合
一个简单的spring boot 和mybatis整合的实例,spring boot 就是spring 与 spring mvc的综合 mybatis就是半自动的orm框架,这是一个简单的整合demo
spring boot mybatis整合
该实例运用的时IDEA 工具开发,项目为grandle项目
spring boot 整合mybatis
基于spring boot, 整合mybatis,自动生成mybatis代码。
spring boot 和mybatis的整合
spring boot 来代替了spring框架,和mybatis进行了整合。
Spring Boot 整合MyBatis快速搭建及测试
Spring Boot 整合代码 IDEA 中可以直接建Spring Boot 项目 pom 文件: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-insta...
spring boot + mybatis + mysql整合项目
一个完整的spring boot + mybatis + mysql整合项目,使用的是springboot和maven的框架,对刚刚学习这方面的可以借鉴一下
spring boot和mybatis整合小项目
spring boot和mybatis整合小项目,仅供参考..............................................................................................
Spring Boot整合MyBatis出现的异常
一.异常信息 说明找不到这个方法,因为IDEA的原因,需要将xxmapper.xml放到classpath下的resources文件夹里 二.解决方式
spring boot整合mybatis出错,有没大神解决下,谢谢
rn2018-04-14 13:13:20.076 INFO 5048 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2264 msrn2018-04-14 13:13:20.246 INFO 5048 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]rn2018-04-14 13:13:20.250 INFO 5048 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]rn2018-04-14 13:13:20.250 INFO 5048 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]rn2018-04-14 13:13:20.250 INFO 5048 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]rn2018-04-14 13:13:20.250 INFO 5048 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]rn2018-04-14 13:13:20.478 INFO 5048 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...rn2018-04-14 13:13:20.620 INFO 5048 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.rn2018-04-14 13:13:20.675 INFO 5048 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'rn2018-04-14 13:13:20.692 INFO 5048 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [rn name: defaultrn ...]rn2018-04-14 13:13:20.803 INFO 5048 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core 5.2.16.Finalrn2018-04-14 13:13:20.804 INFO 5048 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not foundrn2018-04-14 13:13:20.811 WARN 5048 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;rn2018-04-14 13:13:20.812 INFO 5048 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...rn2018-04-14 13:13:20.817 INFO 5048 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.rn2018-04-14 13:13:20.820 INFO 5048 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]rn2018-04-14 13:13:20.835 INFO 5048 --- [ restartedMain] ConditionEvaluationReportLoggingListener : rnrnError starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.rn2018-04-14 13:13:20.851 ERROR 5048 --- [ restartedMain] o.s.boot.SpringApplication : Application run failedrnrnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]rn at com.gzccc.it.ItApplication.main(ItApplication.java:13) [classes/:na]rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]rn at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]rn at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.1.RELEASE.jar:2.0.1.RELEASE]rnCaused by: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;rn at org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor.getValidationMode(PersistenceUnitInfoDescriptor.java:88) ~[hibernate-core-5.2.16.Final.jar:5.2.16.Final]rn at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.mergeSettings(EntityManagerFactoryBuilderImpl.java:455) ~[hibernate-core-5.2.16.Final.jar:5.2.16.Final]rn at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:200) ~[hibernate-core-5.2.16.Final.jar:5.2.16.Final]rn at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:164) ~[hibernate-core-5.2.16.Final.jar:5.2.16.Final]rn at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:51) ~[spring-orm-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) ~[spring-orm-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1761) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1698) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]rn ... 21 common frames omittedrnrnrnProcess finished with exit code 0rn
spring boot 整合mybatis (tk.mybatis)解决的一些问题
时区不统一,但是我和北京时区换算 +8 并没有起作用。 nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: ...
spring和mybatis整合 测试报错 求大神路过解决一下!!!!!!!!
[b]以下是报错内容[/b][color=#FF0000][/color]rnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mybatisTest.test2': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'stuService' is definedrn at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:385)rn at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)rn at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)rn at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:319)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:212)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)rn at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)rn at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)rn at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)rn at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)rn at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)rn at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)rn at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)rnrnrnrn以下是配置文件rnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrnrnrnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrnrnrnrnrnrn rnrn rn rnrnrnrnrndao层rnrnrnpackage com.mapper;rnrnimport java.util.List;rnimport org.springframework.stereotype.Repository;rnimport com.entity.student;rnrn@Repositoryrnpublic interface StuDao rnrn // 按学号查询学生信息rn student findStuBySno(int sno) throws Exception;rnrn // 查询全部学生rn List findStuAll() throws Exception;rnrnrnrnservice层rnpackage com.service;rnrnimport java.util.List;rnrnimport com.entity.student;rnrnpublic interface StuService rnrn public student findStuBySno (int sno) throws Exception;rn rn public List findStuAll() throws Exception;rnrnrnrn实现类rnrnpackage com.serviceImp;rnrnimport java.util.List;rnrnrnimport org.springframework.beans.factory.annotation.Autowired;rnimport org.springframework.stereotype.Service;rnrnimport com.entity.student;rnimport com.mapper.StuDao;rnimport com.service.StuService;rnrn@Service("stuService")rnpublic class StuServiceImp implements StuService rnrn @Autowiredrn private StuDao studao;rn rn rn public student findStuBySno(int sno) throws Exception rn rn return this.studao.findStuBySno(sno);rn rnrn public List findStuAll() throws Exception rn rn return this.studao.findStuAll();rn rnrnrnrn测试类rnrnpackage mybatisTest;rnimport static org.junit.Assert.fail;rnimport javax.annotation.Resource;rnimport org.apache.log4j.Logger;rnimport org.junit.Test;rnimport org.junit.runner.RunWith;rnimport org.springframework.beans.factory.annotation.Autowired;rnimport org.springframework.test.context.ContextConfiguration;rnimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;rnrnimport com.entity.student;rnimport com.service.StuService;rnrn@RunWith(SpringJUnit4ClassRunner.class)rn@ContextConfiguration(locations = "classpath:Spring-*.xml")rnpublic class test2 rn private static Logger logger =Logger.getLogger(test2.class);rn @Resource(name="stuService")rn StuService stuService;rn @Testrn public void testFindStuBySno() throws Exception rn student student=stuService.findStuBySno(123);rn System.out.println(student);rn logger.info(student);rn rn @Testrn public void testFindStuAll() rn fail("Not yet implemented");rn rnrnrn
二十、Spring Boot整合MyBatis(下)
mybatis配置多数据源本篇采用druid作为连接池,配置多个数据源 单数据源,参考>http://blog.csdn.net/l_sail/article/details/70234062 自定义连接池参考>http://blog.csdn.net/l_sail/article/details/70233529maven依赖<?xml version="1.0" encoding="UTF-
Spring Boot笔记(整合Mybatis)
前言 我们知道Spring Boot为我们做了大量配置,简化了Spring应用的搭建以开发过程。毫无疑问,Spring Boot对Mybatis配置也做了同样的简化。首先,我们来梳理一下利用Mybatis开发需要准备的主要工作。 (1)Mybatis基础配置文件,来配置proerpties、settings、typeAliases等等; (2)映射器Mapper接口和XML配置文件; (3...
Spring boot Mybatis 整合(完整版)
做个标记,请移步大神博客:https://blog.csdn.net/winter_chen001/article/details/77249029
Spring Boot整合MyBatis连接数据库
1. 引入依赖 &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;dependency&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;groupId&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;org.mybatis.spring
Spring Boot与MyBatis整合工程
Spring Boot与MyBatis整合工程,介绍文章《【Spring Boot学习总结】12.Spring Boot与MyBatis结合》地址:https://blog.csdn.net/acmman/article/details/82528818
spring Boot整合Mybatis增删改查
适合新手,有问题的话希望大家提出来,我也是刚好用到了,学习一下。
spring boot和mybatis整合(多数据源)
Spring Boot 和 Mybatis 的整合(多数据源),实际生产项目的结构,值得你学习。
spring boot 官方文档翻译之整合 mybatis
直接上代码 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.ap
spring boot 整合jsp与mybatis
spring boot 整合jsp与mybatis框架,可导入之后直接运行。
第三篇:Spring Boot整合MyBatis
本文主要讲解如何在Spring Boot下整合MyBatis,并访问数据库。MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。(如不了解点击前往) 环境依赖 修改 POM 文件,添加mybatis-spring-boot-starter依赖。值得注意的是,可以不添加spring-boot-starter-jdbc。因为,mybatis-spring-boot-st...
Spring Boot整合Mybatis持久层框架
概述 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Spring Boot致力于在蓬勃发展的快速应用开发领域(rapid application development)成为领导者。 MyBatis 本是apache的一个开源...
Spring Boot整合Mybatis之环境搭建
<p>n <span style="color:#424242;font-size:14px;background-color:#FFFFFF;"><span style="color:#424242;font-size:14px;background-color:#FFFFFF;">Spring Boot框架是现在比较热门的微服务框架,很多软件公司都在使用。具有简洁、高效的特点。本套课程以实战为主,以问题场景为导向,</span><span style="color:#424242;font-size:14px;background-color:#FFFFFF;">代码实例讲解</span><span style="color:#424242;font-size:14px;background-color:#FFFFFF;">了Spring Boot用与Web开发的常用的基本规则。学完该套课程后,可以很快上手Spring Boot实战开发以及数据库访问框架Spring Data JPA!</span></span> n</p>n<p>n <br /></p>
spring boot 整合mybatis(多数据源)
spring boot 整合mybatis(多数据源)
Spring Boot + MyBatis + MySQL 整合
SpringBoot+MyBatis+MySQL来实现数据库的操作,附数据库表结构
Spring Boot整合MyBatis(上)
<p>rn <span style="color:#000000;font-size:16px;">本套课程由CSDN学院与咕泡学院共同打造,主要会围绕</span><span style="color:#000000;font-size:16px;">Spring Boot初遇、基本常识、注解和源码分析以及进阶4个方面进行讲解。</span> rn</p>rn<p>rn <span style="color:#000000;font-size:14px;"><br />rn</span> rn</p>rn<p>rn <span style="color:#000000;font-size:16px;">即使你之前从来没有用过Spring Boot也没关系,课程会带领你从0到进阶一步步提升,让你对Spring Boot爱不释手,同时了解Spring Boot的原理和源码。</span> rn</p>
Spring Boot 整合MyBatis的增删改查
       Spring框架非常优秀,但是它最大的问题是每个项目的开发都需要编写大量的配置文件.Spring Boot 的出现就是为了解决Spring框架存在的问题.你可以把它当做Spring MVC的升级版,有Spring MVC方面学习经验的读者可以迅速学会Spring Boot ,因为Spring Boot比Spring MVC简单的不是一点点,让你完全沉浸于业务的思考编码,不用考虑后期繁...
spring boot整合 mybatis 和 hikariCP
附件是spring boot整合mybatis和hikariCP的示例,本demo的spring boot是2.0以下版本,spring boot 2.0以上版本默认的数据库连接池就是hikariCP。
Spring Boot与Mybatis的整合--源码
Spring Boot与Mybatis的整合,非常贴近于实际生产项目的结构。
spring boot整合mybatis示例代码
前段时间自学spring boot 【 springboot学习记录】,mybatis【mybatis学习笔记】以及 springboot如何整合mybatis,写的测试项目 项目源码下载地址:spring boot整合mybatis 本套源码整合了 1.mybatis-generator自动生成代码 2.热部署 3.定时器 4.分页查询 5.读取静态资源文件 6.加密解密公共方法...
Spring 整合mybatis 出现错误,求大神帮忙指点
2个项目,项目A打成jar包,引入到项目B中rn两个项目是可以正常运行访问的,但是把项目A打成jar包引入到项目中,启动就报以下错误:rnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping#0' defined in URL [jar:file:/D:/workSpace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/app-enntry-web/WEB-INF/lib/eshore-khala-core-controller-1.0.0-SNAPSHOT.jar!/conf/spring/spring-mvc-pluginmgr.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'interfaceController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.eshore.backframe.backend.service.IUserService com.eshore.appentry.InterfaceController.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.eshore.backframe.backend.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)rnrnCaused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.eshore.backframe.backend.service.IUserService com.eshore.appentry.InterfaceController.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.eshore.backframe.backend.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)rn at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)rn at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)rn at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)rn ... 47 morernCaused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.eshore.backframe.backend.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:993)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:863)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:775)rn at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)rn ... 49 morernrnrnorg.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.eshore.backframe.backend.service.IUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)rnrn配置文件如下:rnspring-mvc.xml:rnrn rn rn rn rnrnapplicationContext.xml:rnrn rn rn rnrn两个配置文件的beans节点下面都设置了default-autowire="byName" default-lazy-init="true"rnrnrnrn网上找了很多类似的帖子都没解决,求各位大神指教以下,不甚感激
Mybatis整合出现错误。
九月 07, 2017 5:28:58 下午 org.springframework.context.support.GenericApplicationContext refreshrn警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [F:\javaWorkSpace\ssm-crud\target\classes\mapper\DepartmentMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.atguigu.crud.dao.DepartmentMapper.BaseResultMaprn九月 07, 2017 5:28:58 下午 org.springframework.test.context.TestContextManager prepareTestInstancern严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@30c7da1e] to prepare test instance [com.atguigu.crud.test.MapperTest@4681c175]rnjava.lang.IllegalStateException: Failed to load ApplicationContextrn at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)rn at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)rn at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117)rn at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)rn at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)rn at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)rn at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)rn at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)rn at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)rn at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)rn at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)rn at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)rn at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)rn at org.junit.runners.ParentRunner.run(ParentRunner.java:363)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)rnCaused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [F:\javaWorkSpace\ssm-crud\target\classes\mapper\DepartmentMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.atguigu.crud.dao.DepartmentMapper.BaseResultMaprn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742)rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)rn at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:128)rn at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)rn at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:108)rn at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:251)rn at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98)rn at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116)rn ... 25 morernCaused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [F:\javaWorkSpace\ssm-crud\target\classes\mapper\DepartmentMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.atguigu.crud.dao.DepartmentMapper.BaseResultMaprn at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:523)rn at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:380)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)rn ... 40 morernCaused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.atguigu.crud.dao.DepartmentMapper.BaseResultMaprn at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:120)rn at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:92)rn at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:521)rn ... 43 morernCaused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.atguigu.crud.dao.DepartmentMapper.BaseResultMaprn at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:859)rn at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:831)rn at org.apache.ibatis.session.Configuration.addResultMap(Configuration.java:613)rn at org.apache.ibatis.builder.MapperBuilderAssistant.addResultMap(MapperBuilderAssistant.java:214)rn at org.apache.ibatis.builder.ResultMapResolver.resolve(ResultMapResolver.java:47)rn at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:285)rn at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:252)rn at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:244)rn at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:116)rn ... 45 morernrnDepartmentMapper.xml文件是自动生成的,下面是Mybatis的整合。rnrn rn rn rn rnMybatis配置文件没有定义mapperrnrn rn rn rn rn rn rn rn rnrn找了好久找不出来问题,大牛们看下,谢谢rn
Spring +MyBatis 整合访问数据库出现错误
Error creating bean with name 'dbcppool' defined in class path resource [spring_mybatis.xml]: Error setting property values;nested exception isorg.springframework.beans.NotWritablePropertyException: Invalid property 'uname' of bean class [org.apache.common
哪位大神知道这个错误怎么办
Error 15 error LNK2019: unresolved external symbol "public: __thiscall Grid::~Grid(void)" (??1Grid@@QAE@XZ) referenced in function "public: void * __thiscall Grid::`scalar deleting destructor'(unsigned int)" (??_GGrid@@QAEPAXI@Z) madisplayDoc.obj madisplayrnError 16 error LNK2019: unresolved external symbol "public: __thiscall Grid::Grid(void)" (??0Grid@@QAE@XZ) referenced in function "public: void __thiscall CArray::SetSize(int,int)" (?SetSize@?$CArray@VGrid@@AAV1@@@QAEXHH@Z) madisplayDoc.obj madisplayrn编译之后老是出现此问题,求解
配置Spring boot + MyBatis 项目
<p>n 带你快速入门spring boot + mybatis项目,通过学习这门视频,你会飞快上手mybatis相关的编码工作。n</p>
相关热词 c# login 居中 c# 考试软件 c# 自然语言分析 c# 分段读取文件 c# 泛型反射 c#打断点 c# 时间转多少秒 c# 线程函数加参数 c# modbus 读取 c#查询集合表