No bean named 'transactionManager' available: No matching PlatformTransactionManager bean found for

1、问题:

No bean named 'transactionManager' available: No matching PlatformTransactionManager bean found for qualifier 'transactionManager' - neither qualifier match nor bean name match!     at org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils.q

 

2、原因:

项目中采用的了2个数据源,所以将配置文件中的id为transactionManager改成了transactionManager1。在service层的imp层的代码里加了注解@Transactional,但是@Transactional注解中的默认值是transactionManager

@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface Transactional {

	/**
	 * Alias for {@link #transactionManager}.
	 * @see #transactionManager
	 */
	@AliasFor("transactionManager")
	String value() default "";

3、解决:@Transactional注解中赋值transactionManager

@Transactional(transactionManager="transactionManager1")

你可能感兴趣的:(javaweb,数据库,java)