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;
        }

    抽取接口示意图

  • 相关阅读:
    c#中ref与out区别
    【转载】Firebug中net面板的使用
    结构声明、定义
    开始旅程了
    strcpy、strcat、strcmp、strlen
    #include 格式
    宏定义
    MySQL 字段类型
    MySQL 约束类型
    (转载)C#语言之“string格式的日期时间字符串转为DateTime类型”的方法
  • 原文地址:https://www.cnblogs.com/sdgtxuyong/p/14720689.html
Copyright © 2011-2022 走看看