现象:

按照教程步骤做的,但连单元测试都无法通过,会出现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. Android Studio的xml文件无法代码提示

    之前试了省电模式.清理缓存.重新勾选sdk都没有任何用 于是我开始乱搞,总结了以下方法: 找到Gradle Script中的build.gradle(Module:XXXX) 修改compileSdk ...

  2. HFS~HTTP File Server 2.4rc2 20191231

    后台,打卡,这有的 电脑 PC   浏览器 打开 安卓平台,浏览器,打开,界面

  3. 特别好用的题库(oj)

    tk.hustoj.com 每次做题时,我都会对"外部导入"这四个字感到迷惑: 这些题,究竟是从哪里"导入"的? 我们不为而知...... 直到后来...... ...

  4. AspectRatio、Card 卡片组件

    一.Flutter AspectRatio 组件 AspectRatio 的作用是根据设置调整子元素 child 的宽高比. AspectRatio 首先会在布局限制条件允许的范围内尽可能的扩展,wi ...

  5. 7款WordPress图片分离对象存储插件 含国内主流云服务存储商

    如果我们有用WordPress搭建网站的朋友应该会发现网站文件和数据库其实没有多大,在网站运营几年后数据最大的就是图片.而且图片占用服务器的空间会搬家比较麻烦,而且占用服务求的带宽.我们看到很多的Wo ...

  6. 简述47种Shader Map的渲染原理与制作方法

    https://mp.weixin.qq.com/s/6EVpmgC53HqklIVkIpEssg

  7. JDBC之Statement

    Statement 目录 Statement Statement Statement概述 要执行的SQL分为两类 查询 增删改 Statement继承体系 SQL注入问题 SQL注入问题解决 获取得到 ...

  8. 问题记录之---nginx temp文件夹

    问题说明: 服务从外网访问服务公众号前端调用后端接口时候会偶然出现网络异常情况(并非每次都会出现),此问题只是偶发性得,问题现象如下图: 查看nginx错误日志有以下内容:open() "/ ...

  9. Color the ball HDU - 1556 _差分

    N名同学拍成一排,编号为1,2,3,4 -- N.现在有一位老师需要检查所有同学的出勤情况,他会进行点名,每次给出两个数a,b,并且保证a小于等于b,这个区间内的所有同学都会被点名一次,老师会进行N次 ...

  10. Operator包的应用

    # -*-coding:utf-8-*- import operator print(operator.add(1,1))    #  加 print(operator.sub(2,1))    #减 ...