struts2+;spring4&x2B;mybatis3如果使用@Transactional将是一个错误(自动连线(必需=true))

struts2+;spring4&x2B;mybatis3如果使用@Transactional将是一个错误(自动连线(必需=true)),spring,Spring,我正在使用spring@Transactional来管理MySQL事务。 但是我添加@Transactional的方式是错误的 @Service //@Transactional(readOnly = true) public class UserInfoService extends BaseService @Autowired private UserInfoAccessor userInfoAccessor; //@Transactional

我正在使用spring
@Transactional
来管理MySQL事务。 但是我添加
@Transactional
的方式是错误的

@Service
//@Transactional(readOnly = true)
public class UserInfoService extends BaseService

    @Autowired
    private UserInfoAccessor userInfoAccessor;
        //@Transactional
        public void insert()
            Map<String, String> map = new HashMap<>();
            map.put("userName", "test");
            userInfoAccessor.insert(map);
您可以下载我的项目源代码


正确的设置方法是什么?

您收到的错误是找不到
UserInfoService
自动连接到
IndexAction.UserInfoService
,这可能与
@Transactional
无关。如果您下载我的项目,请取消UserInfoService.java 22行(//@Transactional)的注释然后再试一次谢谢您遇到的错误是找不到一个
UserInfoService
自动连接到
IndexAction.UserInfoService
,这可能与
@Transactional
无关。如果您下载了我的项目,请取消对UserInfoService.java 22行(//@Transactional)的注释,然后再试一次谢谢
Unable to instantiate Action, com.luotuo.xiaobao.action.IndexAction, defined for 'index' in namespace '/'Error creating bean with name 'com.luotuo.xiaobao.action.IndexAction': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.luotuo.xiaobao.service.UserInfoService com.luotuo.xiaobao.action.IndexAction.userInfoService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.luotuo.xiaobao.service.UserInfoService] 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)