调用网址时,我的项目出现问题。 这是我的applicationContext
<context:component-scan base-package="com.prova" />
<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean id="dataSource"
<!-- connection to datasource -->
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.prova.model"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.id.new_generator_mappings">false</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager"
name ="transactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
这是我的控制器
package com.prova.controller;
<!-- import -->
@Controller
public class EmployeeController {
private static final Logger logger = Logger
.getLogger(EmployeeController.class);
public EmployeeController() {
System.out.println("EmployeeController()");
}
@Autowired
private EmployeeService employeeService;
@RequestMapping(value = "/all")
public ModelAndView listEmployee(ModelAndView model) throws IOException {
List<Employee> listEmployee = employeeService.getAllEmployees();
model.addObject("listEmployee", listEmployee);
model.setViewName("home");
return model;
}
...
...
...
当我在邮递员中呼叫网址http://localhost:8082/prova/all时,我收到此错误:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined: No matching PlatformTransactionManager bean found for qualifier 'transactionManager' - neither qualifier match nor bean name match!
请帮助我,因为我尝试了所有解决方案。 谢谢!