现象:

按照教程步骤做的,但连单元测试都无法通过,会出现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. 第二周day5

    第二周day5,星期五 所花时间:1h 代码量: 搏客量:1 了解到的知识点:学习了安卓的帧布局表格布局和约束布局的相关知识,并完成了对应的习题.

  2. Python占位符总结:%方式和format方式

    Python中,我们在预定义某类具有相似格式的变量或者输出一句含有多个变量的提示语句时,往往用到占位符,而占位符有两种表达方式: %方式: 下面这段代码摘自matplotlib的_init_.py文件 ...

  3. 解决问题mount.nfs: Stale file handle

    原因出现在,机器1挂载了机器2的一个盘,然后机器2重启了,然后机器1变成没有响应的状态,然后卸载了机器1的对于这个盘的挂载,然后就一直挂不上,提示mount.nfs: Stale file handl ...

  4. 微信小程序-通过绑定事件进行传值

    一.数据绑定: <view bindtap="node" data-num="5"> 点击传值:{{nums}} </view> dat ...

  5. ScrollView 滚动条

    <style name="fa_SlideTabRecyclerView"> <item name="android:scrollbarThumbVer ...

  6. webpack-dev-middleware改造成koa中件间

    const webpackDev = require('webpack-dev-middleware'); function applyMiddleware(middleware, req, res) ...

  7. vscode 开发Vue项目

    写在开头 Vue作为前端项目,本身不依赖IDE,完全可以使用任何文本编辑器进行开发.我使用vscode仅是因为比较习惯,vscode几乎可以作为任何项目的开发IDE. 环境安装 安装nodejs,去官 ...

  8. HTML+CSS+JS制作一个黑灰色简约时钟

    HTML+CSS+JS制作一个黑灰色简约时钟 1. 效果图: 2. 特点:这次借鉴了网络上的代码,利用JS动态创建元素,减少html语句的数量,也便于与vue.react等语言进行结合. 3. 代码实 ...

  9. Spark之详解及性能优化

    一.spark简介 Apache Spark是一个围绕速度.易用性和复杂分析构建的大数据处理框架. Spark是用Scala程序设计语言编写而成,运行于Java虚拟机(JVM)环境之上.目前支持如下程 ...

  10. 34.MySQL 架构

    一主两从 双机热备 原理: