Spring 春季4&x2B;Hibernate 5:没有名为'的bean;交易经理';定义
当我调用URL时,我的项目有问题。 这是我的应用程序上下文Spring 春季4&x2B;Hibernate 5:没有名为'的bean;交易经理';定义,spring,transactionmanager,Spring,Transactionmanager,当我调用URL时,我的项目有问题。 这是我的应用程序上下文 <context:component-scan base-package="com.prova" /> <mvc:annotation-driven /> <mvc:resources mapping="/resources/**" location="/resources/" /> <bean id="dataSource" <!-- c
<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;
}
...
...
...
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!