Skip to content

声明式编程,专注业务而非底层细节

@Transactional@Async@Scheduled@Cacheable 这类注解, 只需要声明功能,不需要手动编写事务、线程、定时、缓存的底层代码,让开发者专注业务逻辑。

声明式事务

1
2
3
4
5
6
7
@Service
public class OrderService {
    @Transactional // 只需添加注解,Spring 自动处理事务
    public void createOrder(Order order) {
        // 业务逻辑
    }
}