qq_39586869 2017-09-13 05:40 采纳率: 50%
浏览 969
已结题

有谁能告诉我这个错误该怎么改正??。。。。。

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'hibernate.dialect' in string value "${hibernate.dialect}"

org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'sessionFactory' defined in class path resource [applicationContext.xml]

附上我的配置文件
<?xml version="1.0" encoding="UTF-8"?>
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">

<context:property-placeholder location="classpath:db.properties"/>

<!-- 整合hibernate的核心配置文件:hibernate.cfg.xml -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <!-- 干掉:工具类 
        还是要读取hibernate的核心配置文件
    -->
    <!-- <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> -->
    <!-- 干掉:hibernate.cfg.xml 
        数据源、属性、映射文件
    -->
    <property name="dataSource" ref="dataSource"></property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.format_sql">true</prop>
        </props>
    </property>
    <property name="mappingResources">
        <array>
            <value>com/lhj/pojo/user.hbm.xml</value>
        </array>
    </property>

</bean>
<!-- 数据源 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${hibernate.driver}"></property>
    <property name="url" value="${hibernate.url}"></property>
    <property name="username" value="${hibernate.username}"></property>
    <property name="password" value="${hibernate.password}"></property>
</bean>

<!-- 事物管理bean -->
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<!-- 事物管理 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <!-- propagation:事物的传播特性
                REQUIRED:有就使用,没有的话,就创建事物
                REQUIRES_NEW:每次都创建一个新的事物
         -->
        <tx:method name="save*" propagation="REQUIRED" />
        <tx:method name="update*"/>
        <tx:method name="*" read-only="true"/>
    </tx:attributes>
</tx:advice>
<!-- 配置切面 -->
<aop:config>
    <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.bjsxt.service.*.*(..))"/>
</aop:config>

    <!-- 管理dao -->
<bean id="userDaoImpl" class="com.lhj.dao.impl.UserDaoImpl">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 管理service -->
<bean id="userServiceImpl" class="com.lhj.service.impl.UserServiceImpl">
    <property name="userDaoImpl" ref="userDaoImpl"></property>
</bean>

  • 写回答

3条回答

  • cashT 2017-09-13 06:41
    关注

    传入参数不合法导致,在错误的地方打个断点,debug一下,看看到底哪里的问题.

    评论

报告相同问题?

悬赏问题

  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了