zoukankan      html  css  js  c++  java
  • service层,抽取为接口,开启事务

    抽取为接口后,

    springboot事务开启,不在报错。

    @Transactional
    public interface DescriptionService {
    
        
        public Description addDescription(Description description) ;

    启动类

    @SpringBootApplication
    @EnableTransactionManagement
    @MapperScan(basePackages = {"cn.taotao.dao"})
    @EnableRedisHttpSession(maxInactiveIntervalInSeconds = 20*60)
    @EnableCaching
    public class Zhouyi3Application {
    
        
        public static void main(String[] args) {
            SpringApplication.run(Zhouyi3Application.class, args);
        }
    
        
    }

    springboot的redis注解,不再报错。

    @Service
    public class DescriptionServiceImpl implements DescriptionService {
    
        @Autowired
        private DescriptionMapper descriptionMapper;
        @Autowired
        private CategoryService categoryService;
        
        //@CachePut(cacheNames = "Description",key = "#description.id")
        public Description addDescription(Description description) {
            descriptionMapper.addDescription(description);
            descriptionMapper.updateDescriptionOrder(description.getId(), description.getId()*10);
            return description;
        }
        
        @CachePut(cacheNames = "Description",key="'id:'+#description.id")
        public Description modifyDescription(Description description) {
            descriptionMapper.modifyDescription(description);
            return description;
        }

    抽取接口示意图

  • 相关阅读:
    Django REST Framework
    Django REST Framework 序列化和校验 知识点
    Django REST Framework 数码宝贝
    浏览器的跨域解决方案
    Django Rest Framework 简介及 初步使用
    javaScript
    jQuery 事件流的概念
    jQuery 文档操作
    Django
    crm 系统项目(三) 业务
  • 原文地址:https://www.cnblogs.com/sdgtxuyong/p/14720689.html
Copyright © 2011-2022 走看看