首次搭建springmvc 首次运行出错
Servlet/springMVCthrewload()exceptionorg.springframework.beans.factory.NoSuchBeanDefi...
Servlet /springMVC threw load() exception
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.mvc.service.StudentService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
applicationContext配置:
<context:annotation-config />
<context:component-scan base-package="com.mvc" />
<mvc:annotation-driven></mvc:annotation-driven>
<aop:aspectj-autoproxy/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="show_sql">true</prop>
<prop key="format_sql">true</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.mvc.entity</value><!-- 扫描实体类,也就是平时所说的model -->
</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
不知道那里出问题了 展开
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.mvc.service.StudentService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
applicationContext配置:
<context:annotation-config />
<context:component-scan base-package="com.mvc" />
<mvc:annotation-driven></mvc:annotation-driven>
<aop:aspectj-autoproxy/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="show_sql">true</prop>
<prop key="format_sql">true</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.mvc.entity</value><!-- 扫描实体类,也就是平时所说的model -->
</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
不知道那里出问题了 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询