栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Spring5-MySQL-报错Property ‘dataSource‘ is required

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Spring5-MySQL-报错Property ‘dataSource‘ is required

部分错误信息:最主要的是Property 'dataSource' is required

D:jdkjdkbinjava.exe -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:IntelliJ IDEA 2019.1.3libidea_rt.jar=4564:D:IntelliJ IDEA 2019.1.3bin" -Dfile.encoding=UTF-8 -classpath "D:IntelliJ IDEA 2019.1.3libidea_rt.jar;D:IntelliJ IDEA 2019.1.3pluginsjunitlibjunit-rt.jar;D:IntelliJ IDEA 2019.1.3pluginsjunitlibjunit5-rt.jar;D:jdkjdkjrelibcharsets.jar;D:jdkjdkjrelibdeploy.jar;D:jdkjdkjrelibextaccess-bridge-32.jar;D:jdkjdkjrelibextcldrdata.jar;D:jdkjdkjrelibextdnsns.jar;D:jdkjdkjrelibextjaccess.jar;D:jdkjdkjrelibextjfxrt.jar;D:jdkjdkjrelibextlocaledata.jar;D:jdkjdkjrelibextnashorn.jar;D:jdkjdkjrelibextsunec.jar;D:jdkjdkjrelibextsunjce_provider.jar;D:jdkjdkjrelibextsunmscapi.jar;D:jdkjdkjrelibextsunpkcs11.jar;D:jdkjdkjrelibextzipfs.jar;D:jdkjdkjrelibjavaws.jar;D:jdkjdkjrelibjce.jar;D:jdkjdkjrelibjfr.jar;D:jdkjdkjrelibjfxswt.jar;D:jdkjdkjrelibjsse.jar;D:jdkjdkjrelibmanagement-agent.jar;D:jdkjdkjrelibplugin.jar;D:jdkjdkjrelibresources.jar;D:jdkjdkjrelibrt.jar;D:IDEAspring5_demo4outproductionspring5_demo4;D:IDEAspring5_demo4libcommons-logging-1.1.1.jar;D:IDEAspring5_demo4libspring-beans-5.2.6.RELEASE.jar;D:IDEAspring5_demo4libspring-context-5.2.6.RELEASE.jar;D:IDEAspring5_demo4libspring-core-5.2.6.RELEASE.jar;D:IDEAspring5_demo4libspring-expression-5.2.6.RELEASE.jar;C:Users34709.m2repositoryjunitjunit4.12junit-4.12.jar;C:Users34709.m2repositoryorghamcresthamcrest-core1.3hamcrest-core-1.3.jar;D:IDEAspring5_demo4libdruid-1.1.9.jar;D:IDEAspring5_demo4libspring-aop-5.2.6.RELEASE.jar;D:IDEAspring5_demo4libcom.springsource.net.sf.cglib-2.2.0.jar;D:IDEAspring5_demo4libcom.springsource.org.aopalliance-1.0.0.jar;D:IDEAspring5_demo4libcom.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar;D:IDEAspring5_demo4libspring-aspects-5.2.6.RELEASE.jar;D:IDEAspring5_demo4libmysql-connector-java-8.0.23.jar;D:IDEAspring5_demo4libspring-jdbc-5.2.6.RELEASE.jar;D:IDEAspring5_demo4libspring-orm-5.2.6.RELEASE.jar;D:IDEAspring5_demo4libspring-tx-5.2.6.RELEASE.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.atguigu.spring5.test.TestBook,testJdbcTemplate
十月 22, 2021 10:39:21 上午 org.springframework.context.support.AbstractApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookDaoImpl': Unsatisfied dependency expressed through field 'jdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcTemplate' defined in class path resource [bean3.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'dataSource' is required

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookDaoImpl': Unsatisfied dependency expressed through field 'jdbcTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcTemplate' defined in class path resource [bean3.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'dataSource' is required

	
Caused by: java.lang.IllegalArgumentException: Property 'dataSource' is required
	at org.springframework.jdbc.support.JdbcAccessor.afterPropertiesSet(JdbcAccessor.java:160)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
	... 47 more


Process finished with exit code -1

这是因为我们配置dataSource后没有连接需要添加如代码

    
    
        
    
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/343641.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号