成功解决:com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl.

简介: 这篇文章提供了解决Spring整合MyBatis时报错的配置方法,包括使用Spring的上下文属性占位符加载数据库配置文件`db.properties`,并在Spring配置文件中声明并配置数据源`DruidDataSource`。

🏆 没有伞的孩子、只能用力奔跑。向着架构师的方向努力、做一个有始有终的人。

前言

使用Spring 整合 mybatis的时候 报错了

解决方法

这里是正确的配置

    <!--加载数据库配置文件-->
    <context:property-placeholder location="classpath:db.properties"/>
    <!--声明数据源-->
    <bean id="myDataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
        <!--使用db配置文件读取数据库信息,格式类似el表达式-->
        <property name="driverClassName" value="${jdbc.driverClassName}"></property>
        <property name="url" value="${jdbc.url}"></property>
        <property name="username" value="${jdbc.username}"></property>
        <property name="password" value="${jdbc.password}"></property>
    </bean>

单独的文件 db.properties

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/spring_test?serverTimezone=UTC&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;useSSL=false
jdbc.username=root
jdbc.password=root
相关文章
org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.
org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.
|
2月前
|
Java
flyway报错Caused by: java.lang.NoSuchMethodError: org.flywaydb.core.api.configuration.FluentConfigurat
flyway报错Caused by: java.lang.NoSuchMethodError: org.flywaydb.core.api.configuration.FluentConfigurat
40 2
|
3月前
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
100 0
|
5月前
【ERROR】No qualifying bean of type ‘com.alibaba.druid.pool.DruidDataSource‘ available
【ERROR】No qualifying bean of type ‘com.alibaba.druid.pool.DruidDataSource‘ available
57 0
|
XML Java 数据库连接
解决在mybatis中出现的org.apache.ibatis.exceptions.PersistenceException~
解决在mybatis中出现的org.apache.ibatis.exceptions.PersistenceException~
1115 0
|
Java 微服务 Spring
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
243 0
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServer
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServer
|
Java 数据库连接 数据库
org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.问题的解决
org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.问题的解决
235 0
|
druid
java.lang.IllegalStateException: Error processing condition on com.alibaba.druid.spring.boot.autocon
java.lang.IllegalStateException: Error processing condition on com.alibaba.druid.spring.boot.autocon
382 0
|
Java Maven
Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log 解决方法
org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:400) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.jav
241 0