编辑 | blame | 历史 | 原始文档

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

This is a Spring Boot 3.1.5 application with Java 17 that provides a dynamic menu system with tree structure. The application uses Microsoft SQL Server 2019 database with MyBatis Plus for data access and serves REST APIs for menu management.

Key Technologies and Dependencies

  • Spring Boot 3.1.5 with Java 17
  • Microsoft SQL Server 2019 with MSSQL-JDBC driver
  • MyBatis Plus for ORM and database operations
  • Alibaba Druid for connection pooling
  • Lombok for reducing boilerplate code
  • Alibaba FastJSON for JSON serialization
  • Hutool utility library

Development Commands

Build and Package

mvn clean package

Run Application

mvn spring-boot:run

Run Tests

mvn test

Generate JAR with dependencies

mvn clean package -DskipTests

Run Production JAR

Use the provided startup script:
```bash

Windows

src/main/startup.bat

Or manually with custom SQL Server connection:

java -jar -Dspring.datasource.url="jdbc:sqlserver://HOST:PORT;databaseName=DATABASE;encrypt=true;trustServerCertificate=true" -Dspring.datasource.username=USERNAME -Dspring.datasource.password=PASSWORD simple.jar
```

Note: Both encrypt=true and encrypt=false work with trustServerCertificate=true. The startup.bat uses encrypt=true.

Application Architecture

Package Structure

  • com.gs.simple - Root package
  • common/ - Shared utilities (DatabaseConfig, ResultDto)
  • controller/ - REST controllers
  • domain/ - Entity classes (MesSimplesimple, TreeView, Children)
  • mapper/ - MyBatis mappers for database access
  • service/ - Business logic layer with implementation

Key Components

SimpleController (controller/SimpleController.java:16-35)
- Main REST controller with CORS enabled
- Endpoints: /simple/getTree (POST) and /simple/list (POST)

MesSimpleService (service/MesSimpleService.java:15-23)
- Core business logic for menu operations
- Methods: getTree(), toTree(), getMenuList()

TreeView Domain (domain/TreeView.java:13-24)
- Represents hierarchical menu structure with id, title, field, spread, and children

Database Configuration

  • Default: SQL Server database at 192.168.0.51:1433 (database: TEST_MES)
  • Schema Initialization: Use MES_SIMPLE_CREATE_TABLE.sql to create the required database table
  • Runtime Override: Use system properties or startup.bat for different environments without rebuilding
  • Connection Pool: Druid with 5-20 connections, 60s timeout
  • MyBatis: XML mappers in src/main/resources/mapper/

Development Notes

  • Server runs on port 9091 by default
  • Spring Boot Actuator endpoints available for monitoring
  • MyBatis Plus uses AUTO ID generation strategy
  • SQL logging enabled via StdOutImpl for debugging
  • Camel case mapping enabled for SQL Server database columns
  • JDBC null handling configured for SQL Server compatibility (jdbc-type-for-null: 'null')
  • Application supports runtime database configuration override via JVM properties
  • Druid SQL wall filter enabled for SQL injection protection with multi-statement support