u011404046
名字随便取吧
2016-05-22 16:14

IDEA开发JavaWeb(SpringMVC+MyBatis)项目报错。

刚开始JavaWeb的开发,用了SpringMVC+Mybatis的结构,按着教程来的,但是运行欢迎页能看到,但是报了Injection of resource dependencies failed.错误,Dao没找到。
这是工程的结构。
图片说明
这是applicationContext.xml的配置。

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/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:jdbc.properties"/>

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="${driver}"/>
    <property name="jdbcUrl" value="${url}"/>
    <property name="user" value="${username}"/>
    <property name="password" value="${password}"/>

    <property name="maxPoolSize" value="30"/>
    <property name="minPoolSize" value="10"/>
    <property name="autoCommitOnClose" value="false"/>
    <property name="checkoutTimeout" value="1000"/>
    <property name="acquireRetryAttempts" value="2"/>
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="configLocation" value="classpath:mybatis-config.xml"/>
    <property name="typeAliasesPackage" value="com.laxus.photoaesthetic.entity"/>
    <property name="mapperLocations" value="classpath:mapper/UserDao.xml"/>

</bean>

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
    <property name="basePackage" value="com.laxus.photoaesthetic.daos"/>
</bean>

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答