qq_38500534
qq_38500534
采纳率0%
2017-04-25 09:39 阅读 1.0k

Spring整合扫描不到Mybatis的config文件,急急急急,求大神解答

<?xml version="1.0" encoding="UTF-8"?>
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
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-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.0.xsd">

<!-- 数据库连接池 -->
<!-- 加载配置文件 -->
<context:property-placeholder location="classpath:resource/*.properties" />
<!-- 数据库连接池 dbcp-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="url" value="jdbc:sqlserver://192.168.0.103;DatabaseName=YanShu_Crawler" />
    <property name="username" value="sa" />
    <property name="password" value="zxasqw12/*" />
    <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
</bean>
<!-- 配置sqlsessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="configLocation" value="classpath:SqlMapConfig.xml"></property>  
</bean>
<!-- 配置扫描包,加载mapper代理对象 -->
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="sqlSessionFactor" ref="sqlSessionFactory"></property>
    <property name="basePackage" value="com.mapper"></property>
</bean>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • younghaodaydayupup younghaodaydayupup 2017-04-25 09:42

    是不是你的resource文件夹不是源文件夹?

    点赞 评论 复制链接分享
  • sun1021873926 夕阳雨晴 2017-04-25 10:47

    http://blog.csdn.net/xlgen157387/article/details/46841245

     <context:property-placeholder location="classpath*:*.properties"
                                      ignore-unresolvable="true"/>
    
    点赞 评论 复制链接分享

相关推荐