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#调用JS
    C#对象序列化(2)
    C#委托和事件(2)
    C#委托和事件(1)
    Windows Mobile Ping 命令实现
    操作 SQL Server Mobile 2005 数据库的常用 C# 代码
    Pocket PC 2003数据库操作
    C#委托和事件(3)
    C#中RSA加密解密和签名与验证的实现
    使用SqlBulkCopy数据导入和复制
  • 原文地址:https://www.cnblogs.com/sdgtxuyong/p/14720689.html
Copyright © 2011-2022 走看看