现象:

按照教程步骤做的,但连单元测试都无法通过,会出现java.lang.IllegalArgumentException: Property ‘dataSource’ is required这个错误。

原因:

通过看错误提示怀疑是properties文件没有被加载进来,仔细检测发现路径没有写错。后面发现是版本不一样导致的,我一不小心升级成了2021.3版本,创建javaEE的过程和视频中的不一样,工程结构也不一样。

解决办法:

在用Jdbc访问数据库时,视频中是将druid.properties文件配置到src文件夹下时;2021.3版本是放到src/main/resources文件夹下。这样才会在编译的时候在target文件夹下生成配置文件。

黑马 java.lang.IllegalArgumentException: Property ‘dataSource‘ is required的更多相关文章

  1. MyBatis与Spring MVC结合时,使用DAO注入出现:Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    错误源自使用了这个例子:http://www.yihaomen.com/article/java/336.htm,如果运行时会出现如下错误: Invocation of init method fai ...

  2. Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required [ IDEA mybatis项目报错 ]

    今天笔者用Springboot框架整合Mybatis做一个小小的项目: 代码写完,在运行项目时,IDEA给我报了3处错误: org.springframework.beans.factory.Unsa ...

  3. springboot整合mybatis的时候报错Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    今天闲来无事,学习springboot整合mybatis,在bilibili看视频学的,视频中在dao层的interface上面加上org.apache.ibatis.annotations.Mapp ...

  4. 使用 Jenkins 打包成功后 运行 出现 Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    linux 运行时 错误日志 Error starting ApplicationContext. To display the conditions report re-run your appli ...

  5. springmvc与mybatis整合时 java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required 异常

    今天在整合springmvc与mybatis时,启动服务器遇到这样一个问题, by: java.lang.IllegalArgumentException: Property 'sqlSessionF ...

  6. springboot下Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

    已检查jar包是否引入 <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId ...

  7. java.lang.IllegalArgumentException: Attribute 'items' is required and must be a Collection, an Array or a Map

    很有可能是涉及items的时候写成了item导致此错

  8. spring boot :error querying database. Cause: java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required

    配置多个数据源启动报错,error querying database. Cause: java.lang.IllegalArgumentException: dataSource or dataSo ...

  9. IDEA报错: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"

    运行审核流模块: 在ActivitiServiceApplication模块日志报错: Error starting ApplicationContext. To display the auto-c ...

  10. java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required

    java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required 严重: Exceptio ...

随机推荐

  1. 兼容ie8的Html+Css+Js

    1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset=" ...

  2. DOM DEM DLG DRG

    以下有不同的说法,但是意思都很相近.一. DOM (数字正射影像图):利用数字高程模型对扫描处理的数字化的航空相片.遥感影像,经逐个像元纠正,按图幅范围裁切生成的影像数据,它的信息比较直观,具有良好的 ...

  3. php 动态实例化某个类

    $name = 'test'; $controller = 'test'; $a = '\\addons\\'.$name.'\\model\\'.$controller; $this->mod ...

  4. php严格模式的使用

    <?php declare (strict_types = 1); namespace app\controller; use app\BaseController; use think\fac ...

  5. Day21 21.2:CrawlSpider-redis分布式爬虫

    CrawlSpider-redis分布式 分布式在日常开发中并不常用,只是一个噱头! 概念: 可以使用多台电脑搭建一个分布式机群,使得多台对电脑可以对同一个网站的数据进行联合且分布的数据爬取. 声明: ...

  6. [AGC033C] Removing Coins

    个人思路: 每轮会删掉除选定节点外的所有叶子节点. 黑白染色,但是不会推 SG 函数. 然后就不会了. 正解: 每次直径长度 \(-1\) 或 \(-2\).\(0\) 必胜,\(1\) 必败,\(2 ...

  7. TypeScript Number

    TypeScript Number TypeScript 与 JavaScript 类似,支持 Number 对象. Number 对象是原始数值的包装对象. 语法 var num = new Num ...

  8. Python3之并发(五)---线程条件(Condition)和事件(Event)

    一.线程条件Condition(条件变量) 依赖锁对象(Lock,RLock),锁对象可以通过参数传入获得,或者使用自动创建的默认锁对象当多个条件变量需要共享同一个锁时,建议传入锁对象 除了带有获取到 ...

  9. LoadRunner 常见错误

    1.LoadRunner录制脚本时为什么不弹出IE浏览器? 当一台主机上安装多个浏览器时,LoadRunner录制脚本经常遇到不能打开浏览器的情况,可以用下面的方法来解决. 启动浏览器,打开Inter ...

  10. shell_Day01

    1.判断/etc/inittab文件是否大于100行,如果大于,则显示"/etc/inittab is a big file."否者显示"/etc/inittab is ...