技术文章

记录学习过程,分享技术心得

Spring Boot 快速入门指南

什么是 Spring Boot

Spring Boot 是基于 Spring 框架的快速开发脚手架,它简化了 Spring 应用的初始搭建和开发过程。通过约定优于配置的理念,让开发者能够快速构建生产级别的应用。

核心特性

快速开始

// 1. 创建主类
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

// 2. 创建 Controller
@RestController
@RequestMapping("/api")
public class HelloController {
    @GetMapping("/hello")
    public String hello() {
        return "Hello, Spring Boot!";
    }
}

学习资源

官方文档:https://spring.io/projects/spring-boot

MyBatis 实战教程

MyBatis 简介

MyBatis 是一款优秀的持久层框架,它支持自定义 SQL、存储过程以及高级映射。MyBatis 免除了几乎所有的 JDBC 代码以及设置参数和获取结果集的工作。

核心概念

基本用法

// Mapper 接口
@Mapper
public interface UserMapper {
    @Select("SELECT * FROM users WHERE id = #{id}")
    User findById(Long id);
    
    @Insert("INSERT INTO users(name, email) VALUES(#{name}, #{email})")
    int insert(User user);
}

// 使用示例
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    
    public User getUser(Long id) {
        return userMapper.findById(id);
    }
}

最佳实践

uni-app 跨平台开发实践

什么是 uni-app

uni-app 是一个使用 Vue.js 开发所有前端应用的框架,开发者编写一套代码,可发布到iOS、Android、Web以及各种小程序平台。

核心特性

快速开始

# 全局安装 vue-cli
npm install -g @vue/cli

# 创建 uni-app 项目
vue create -p dcloudio/uni-preset-vue my-project

# 运行到微信小程序
npm run dev:mp-weixin

学习资源

官方文档:https://uniapp.dcloud.net.cn/

Java 并发编程基础

为什么需要并发编程

在多核处理器时代,合理利用并发可以显著提升程序性能。Java 提供了丰富的并发工具,帮助开发者编写高效的多线程程序。

核心概念

基本示例

// 创建线程
Thread thread = new Thread(() -> {
    System.out.println("Hello from thread!");
});
thread.start();

// 使用线程池
ExecutorService executor = Executors.newFixedThreadPool(10);
executor.submit(() -> {
    // 执行任务
});
executor.shutdown();

// 使用 synchronized
public synchronized void increment() {
    count++;
}

常用工具类