您的位置:首页 > 运维架构 > Tomcat

Spring整合web时,tomcat提示ClassNotFound(使用dbcp可以忽略)

2020-01-12 11:38 302 查看

原文链接:https://www.iteye.com/blog/showlike-1931032

web.xml配置ContextLoaderListener属性时,在context-param标签下配置:

<param-value>classpath:applicationContext.xml</param-value>

提示ClassNotFoundException.

查了很多资料。最后解决方案为在service的bean标签内添加属性parent属性,将dao类设置为service的父类:依赖关系为:dao被service依赖。具体操作(红字变化):

    <bean id="userDao" class="com.hebeu.dao.impl.UserDaoImpl">
        <property name="dataSource" ref="dataSource"></property>
    </bean>
    <!-- service -->
    <bean id="userService" class="com.hebeu.service.impl.UserServiceImpl" >
        <property name="userDao" ref="userDao" ></property>
    </bean>

 

|

|

    <bean id="userDao" class="com.hebeu.dao.impl.UserDaoImpl">
        <property name="dataSource" ref="dataSource"></property>
    </bean>
    <!-- service -->
    <bean id="userService" class="com.hebeu.service.impl.UserServiceImpl" parent="userDao">
        <property name="userDao" ref="userDao" ></property>
    </bean>

 

 

  • 点赞
  • 收藏
  • 分享
  • 文章举报
静梵 发布了7 篇原创文章 · 获赞 0 · 访问量 388 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐