駒風少年 2021-10-08 16:59 采纳率: 50%
浏览 714
已结题

Could not resolve placeholder 'jdbc.driver' in value "${jdbc.driver}"

代码

img

<beans xmlns="


xmlns:xsi="
xmlns:context="

   xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">
<context:property-placeholder location="classpath:database.properties"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="${jdbc.driver}"/>
    <property name="jdbcUrl" value="${jdbc.url}"/>
    <property name="user" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" value="dataSource"/>
    <!--   绑定mybatis的配置文件     -->
    <property name="configLocation" value="mybatis-config.xml"/>
</bean>
<!-- 4.配置dao接口扫描包,动态实现了Dao接口可以注入到Spring容器中!   -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
    <property name="basePackage" value="com.kuang.dao"/>
</bean>

问题:at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'jdbc.driver' in value "${jdbc.driver}"

  • 写回答

2条回答 默认 最新

  • CSDN专家-微编程 2021-10-08 17:18
    关注

    为什么不使用阿里的连接池?另外你的连接配置是不是有问题,前面需要加jdbc.吗?你的database.properties里面的key难道是类似jdbc.driver吗?如果key是类似driver=xxx的,配置文件里的变量就不是jdbc.driver而是driver

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月17日
  • 已采纳回答 10月9日
  • 创建了问题 10月8日