未提供参考文件，已跳过文档解析，直接根据用户描述生成工程。

未提供参考文件，已跳过文档解析，直接根据用户描述生成工程。


path


code


gen


-r


uns


/c


ode


e


c


a


f


d


/p


om


.xml


content


xml


version


encoding


UTF


>\n


project


xmlns


http


m


aven


.apache


.org


/P


OM


\"\n


:x


si


www


.w


XML


Schema


-inst


ance


x


:s


chema


Location


http


m


aven


.apache


.org


/P


OM


https


/x


sd


/m


.x


\">\n


model


Version


>\n\n


parent


>\n


groupId


org


.springframework


.boot


artifactId


spring


-b


oot


-st


arter


-parent


version


relative


Path


/>\n


parent


>\n\n


groupId


com


.example


>\n


artifactId


demo


name


description


Demo


Spring


Boot


Project


properties


java


.version


kn


ife


j


>\n\n


d


ependencies


>\n


Web


-->\n


dependency


groupId


org


.springframework


.boot


artifactId


spring


-b


oot


-st


arter


-web


>\n\n


Kn


ife


j


Sw


agger


-->\n


dependency


>\n


groupId


com


.github


.x


ia


oy


min


artifactId


kn


-open


api


-j


ak


arta


spring


-b


oot


-st


arter


>\n


version


ife


j


.version


dependency


>\n\n


Test


-->\n


groupId


org


.springframework


.boot


artifactId


spring


-b


oot


-st


arter


-test


>\n


scope


test


dependency


d


ependencies


>\n\n


build


plugins


plugin


groupId


org


.springframework


.boot


artifactId


spring


-b


oot


-m


aven


-plugin


>\n


project


over


write


true


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.5</version>
        <relativePath/>
    </parent>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>1.0.0</version>
    <name>demo</name>
    <description>Demo Spring Boot Project</description>

    <properties>
        <java.version>17</java.version>
        <knife4j.version>4.5.0</knife4j.version>
    </properties>

    <dependencies>
        <!-- Web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Knife4j + Swagger -->
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
            <version>${knife4j.version}</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/pom.xml


path


code


gen


-r


uns


/c


ode


e


c


a


f


d


README


.md


content


Demo


Project


\n\n


一个


简洁


的


Spring


Boot


Java


单体


后端


工程


。\n\n


技术


栈


\n


M


aven


Kn


ife


j


Open


API


Sw


agger


)\n\n


启动


方式


\n\n


bash


m


vn


spring


-b


oot


run


\n


```\n\n


或


打包


后


运行


：\n\n


package


D


skip


Tests


java


jar


target


/d


emo


.jar


\n


```\n\n


接口


文档


\n\n


启动


后


访问


：\n\n


Kn


ife


j


UI


http


localhost


/doc


.html


\n


Sw


agger


JSON


/v


/api


-d


ocs


\n\n


接口


列表


方法


路径


说明


|\n


GET


api


health


健康


检查


/b


usiness


items


获取


所有


业务


数据


id


根据


ID


POST


新增


|\n


over


write


true


path


code


gen


-r


uns


/c


ode


e


c


a


f


d


/src


/main


/java


/com


example


/d


emo


/D


Application


.java


content


package


com


.example


.demo


;\n\n


import


org


.springframework


.boot


.Spring


;\n


.aut


ocon


figure


Boot


Application


Spring


\n


public


class


Demo


{\n\n


static


void


main


(String


args


{\n


.run


(D


emo


.class


);\n


}\n


over


write


true


path


code


gen


-r


uns


/c


ode


e


c


a


f


d


/src


/main


/java


/com


example


/d


emo


/model


/B


usiness


Item


.java


content


package


com


.example


.demo


.model


;\n\n


import


io


.sw


agger


.v


.o


as


.annotations


media


.Schema


/**\n


业务


数据


模型


\n


*/\n


Schema


description


项


\")\n


public


class


Business


Item


{\n\n


唯一


标识


example


private


Long


id


;\n\n


名称


示例


项目


String


name


Schema


description


描述


这是一个


\")\n


public


Business


Item


{\n


}\n\n


(Long


id


this


.id


;\n


.name


name


.description


description


Long


getId


return


public


void


setId


{\n


}\n\n


String


getName


setName


(String


this


.name


name


;\n


get


Description


description


set


.description


}\n


over


write


true


path


code


gen


-r


uns


/c


ode


e


c


a


f


d


/src


/main


/java


/com


example


/d


emo


/service


/B


usiness


Service


.java


content


package


com


.example


.demo


.service


;\n\n


import


.model


.B


Item


;\n


org


.springframework


.stereotype


.Service


java


.util


.ArrayList


.List


.Map


.Opt


ional


.concurrent


.Con


current


HashMap


import


atomic


.At


omic


Long


;\n\n


/**\n


业务


服务


基于


内存


假


数据


后续


可


替换


为


数据库


实现


\n


*/\n


@Service


public


class


Business


Service


{\n\n


private


final


Map


Long


Item


store


new


Concurrent


HashMap


<>();\n


Atomic


id


Generator


);\n\n


public


Business


Service


{\n


初始化


假


数据


\n


init


Mock


Data


();\n


}\n\n


private


void


save


(new


Item


(null


项目


Alpha


描述


\"));\n


Business


Beta


Gamma


/**\n


获取


所有


业务


数据


\n


*/\n


public


List


Item


findAll


{\n


return


new


ArrayList


store


.values


());\n


}\n\n


/**\n


根据


ID


获取


业务


数据


\n


*/\n


public


Optional


Business


Item


find


ById


(Long


id


{\n


return


.of


Nullable


store


.get


(id


));\n


}\n\n


/**\n


新增


业务


数据


\n


*/\n


public


Business


Item


save


(B


usiness


item


{\n


if


.getId


.set


Id


(id


Generator


.get


And


In


crement


());\n


}\n


store


.put


(item


item


);\n


return


;\n


over


write


true


path


code


gen


-r


uns


/c


ode


e


c


a


f


d


/src


/main


/java


/com


example


/d


emo


controller


Health


Controller


.java


content


package


com


.example


.demo


.controller


;\n\n


import


io


.sw


agger


.v


.o


as


.annotations


Operation


;\n


.t


ags


.Tag


org


.springframework


.web


.bind


.annotation


.Get


Mapping


import


.Request


.Rest


Controller


;\n\n


java


.time


.Local


DateTime


;\n


.util


.Map


Tag


(name


健康


检查


\")\n


RestController


\n


@RequestMapping


api


health


public


class


Health


Controller


{\n\n


Operation


(sum


mary


description


返回


服务


运行


状态


\")\n


GetMapping


\n


Map


<String


Object


health


{\n


return


.of


(\n


status


UP


\",\n


timestamp


Local


DateTime


.now


toString


()\n


);\n


}\n


over


write


true


path


code


gen


-r


uns


/c


ode


e


c


a


f


d


/src


/main


/java


/com


example


/d


emo


controller


/B


usiness


Controller


.java


content


package


com


.example


.demo


.controller


;\n\n


import


.model


.B


Item


;\n


.service


Service


io


.sw


agger


.v


.o


as


.annotations


Operation


.Par


ameter


import


.t


ags


.Tag


;\n


org


.springframework


.http


.Http


Status


.Response


Entity


.web


.bind


.annotation


.*;\n\n


java


.util


.List


;\n\n


Tag


(name


业务


管理


\")\n


RestController


\n


@RequestMapping


api


/b


usiness


public


class


Business


Controller


{\n\n


private


final


Service


business


;\n\n


(B


{\n


this


.b


;\n


}\n\n


Operation


(sum


mary


获取


所有


业务


数据


\")\n


GetMapping


items


public


List


Business


Item


getAll


Items


{\n


return


business


Service


.findAll


();\n


}\n\n


Operation


(sum


mary


根据


ID


获取


业务


数据


\")\n


GetMapping


items


id


}\")\n


public


ResponseEntity


Business


Item


get


ById


(\n


Parameter


description


ID


PathVariable


Long


{\n


return


business


Service


.findById


(id


)\n


map


Response


Entity


ok


or


Else


.not


Found


build


());\n


}\n\n


Operation


(sum


mary


新增


业务


数据


\")\n


Post


Mapping


items


public


ResponseEntity


Business


Item


create


RequestBody


item


{\n


saved


business


Service


.save


(item


);\n


return


.status


(Http


Status


.C


RE


ATED


body


(saved


}\n


over


write


true


path


code


gen


-r


uns


/c


ode


e


c


a


f


d


/src


/main


/java


/com


example


/d


emo


/config


Open


Api


Config


.java


content


package


com


.example


.demo


.config


;\n\n


import


io


.sw


agger


.v


.o


as


.models


.Open


API


;\n


.info


.Cont


act


Info


org


.springframework


.context


.annotation


Bean


import


.Configuration


;\n\n


Configuration


\n


public


class


Open


Api


Config


{\n\n


API


custom


{\n


return


new


()\n


info


(new


Info


title


Demo


\")\n


version


description


Spring


Boot


工程


接口


文档


contact


Contact


name


开发者


email


dev


example


.com


);\n


}\n


over


write


true


path


code


gen


-r


uns


/c


ode


e


c


a


f


d


/src


/main


/resources


application


.yml


content


server


:\n


port


\n\n


spring


name


demo


Kn


ife


j


配置


\n


kn


enable


true


setting


language


zh


-C


N


\n\n


spring


doc


:\n


sw


agger


-ui


path


.html


\n


api


-d


ocs


v


/api


over


write


true


code


gen


-r


uns


/c


ode


e


c


a


f


d


/src


/test


/java


/com


example


/d


emo


/B


usiness


Service


Test


.java


content


package


com


.example


.demo


;\n\n


import


.model


.B


Item


;\n


.service


org


.junit


.jupiter


.api


efore


Each


.Test


java


.util


.List


.Opt


ional


;\n\n


import


static


.Assert


ions


.*;\n\n


/**\n


Business


Service


单元


测试


\n


*/\n


public


class


Test


{\n\n


private


business


;\n\n


Before


Each


void


setUp


{\n


Service


new


Business


();\n


}\n\n


\n


findAll


should


Return


Initial


Mock


Data


List


Item


items


business


.findAll


assertEquals


.size


());\n


Test


void


find


ById


should


Return


When


Exists


{\n


Optional


Business


Item


result


business


Service


.findById


L


);\n


assert


True


(result


.is


Present


());\n


assertEquals


项目


Alpha


.get


getName


}\n\n


Test


\n


void


find


ById


should


Return


Empty


When


Not


Exists


{\n


Optional


Business


Item


result


business


Service


.findById


L


);\n


assert


False


(result


.is


Present


());\n


}\n\n


Test


\n


void


save


should


Assign


Id


And


Store


Item


{\n


Business


new


(null


新


项目


描述


\");\n


saved


business


Service


.save


(new


);\n\n


assert


NotNull


(saved


.getId


());\n


assertEquals


.getName


());\n\n


Optional


Business


Item


found


business


Service


.findById


True


(f


ound


.is


Present


新


项目


描述


.get


get


Description


());\n


}\n


over


write


true


# Demo Project

一个简洁的 Spring Boot 3 + Java 17 单体后端工程。

## 技术栈

- Java 17
- Spring Boot 3.2.5
- Maven
- Knife4j + OpenAPI 3 (Swagger)

## 启动方式

```bash
mvn spring-boot:run
```

或打包后运行：

```bash
mvn package -DskipTests
java -jar target/demo-1.0.0.jar
```

## 接口文档

启动后访问：

- Knife4j UI: http://localhost:8080/doc.html
- Swagger JSON: http://localhost:8080/v3/api-docs

## 接口列表

| 方法 | 路径 | 说明 |
|------|------|------|
| GET | /api/health | 健康检查 |
| GET | /api/business/items | 获取所有业务数据 |
| GET | /api/business/items/{id} | 根据ID获取业务数据 |
| POST | /api/business/items | 新增业务数据 |


package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}


package com.example.demo.model;

import io.swagger.v3.oas.annotations.media.Schema;

/**
 * 业务数据模型
 */
@Schema(description = "业务数据项")
public class BusinessItem {

    @Schema(description = "唯一标识", example = "1")
    private Long id;

    @Schema(description = "名称", example = "示例项目")
    private String name;

    @Schema(description = "描述", example = "这是一个示例描述")
    private String description;

    public BusinessItem() {
    }

    public BusinessItem(Long id, String name, String description) {
        this.id = id;
        this.name = name;
        this.description = description;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}


package com.example.demo.service;

import com.example.demo.model.BusinessItem;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

/**
 * 业务服务 - 基于内存假数据，后续可替换为数据库实现
 */
@Service
public class BusinessService {

    private final Map<Long, BusinessItem> store = new ConcurrentHashMap<>();
    private final AtomicLong idGenerator = new AtomicLong(1);

    public BusinessService() {
        // 初始化假数据
        initMockData();
    }

    private void initMockData() {
        save(new BusinessItem(null, "项目Alpha", "Alpha项目描述"));
        save(new BusinessItem(null, "项目Beta", "Beta项目描述"));
        save(new BusinessItem(null, "项目Gamma", "Gamma项目描述"));
    }

    /**
     * 获取所有业务数据
     */
    public List<BusinessItem> findAll() {
        return new ArrayList<>(store.values());
    }

    /**
     * 根据ID获取业务数据
     */
    public Optional<BusinessItem> findById(Long id) {
        return Optional.ofNullable(store.get(id));
    }

    /**
     * 新增业务数据
     */
    public BusinessItem save(BusinessItem item) {
        if (item.getId() == null) {
            item.setId(idGenerator.getAndIncrement());
        }
        store.put(item.getId(), item);
        return item;
    }
}


package com.example.demo.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.Map;

@Tag(name = "健康检查")
@RestController
@RequestMapping("/api/health")
public class HealthController {

    @Operation(summary = "健康检查", description = "返回服务运行状态")
    @GetMapping
    public Map<String, Object> health() {
        return Map.of(
                "status", "UP",
                "timestamp", LocalDateTime.now().toString()
        );
    }
}


package com.example.demo.controller;

import com.example.demo.model.BusinessItem;
import com.example.demo.service.BusinessService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "业务管理")
@RestController
@RequestMapping("/api/business")
public class BusinessController {

    private final BusinessService businessService;

    public BusinessController(BusinessService businessService) {
        this.businessService = businessService;
    }

    @Operation(summary = "获取所有业务数据")
    @GetMapping("/items")
    public List<BusinessItem> getAllItems() {
        return businessService.findAll();
    }

    @Operation(summary = "根据ID获取业务数据")
    @GetMapping("/items/{id}")
    public ResponseEntity<BusinessItem> getItemById(
            @Parameter(description = "业务ID") @PathVariable Long id) {
        return businessService.findById(id)
                .map(ResponseEntity::ok)
                .orElse(ResponseEntity.notFound().build());
    }

    @Operation(summary = "新增业务数据")
    @PostMapping("/items")
    public ResponseEntity<BusinessItem> createItem(@RequestBody BusinessItem item) {
        BusinessItem saved = businessService.save(item);
        return ResponseEntity.status(HttpStatus.CREATED).body(saved);
    }
}


package com.example.demo.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenApiConfig {

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("Demo API")
                        .version("1.0.0")
                        .description("Spring Boot 3 Demo 工程接口文档")
                        .contact(new Contact()
                                .name("开发者")
                                .email("dev@example.com")));
    }
}


server:
  port: 8080

spring:
  application:
    name: demo

# Knife4j 配置
knife4j:
  enable: true
  setting:
    language: zh-CN

springdoc:
  swagger-ui:
    path: /swagger-ui.html
  api-docs:
    path: /v3/api-docs


package com.example.demo;

import com.example.demo.model.BusinessItem;
import com.example.demo.service.BusinessService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.*;

/**
 * BusinessService 单元测试
 */
public class BusinessServiceTest {

    private BusinessService businessService;

    @BeforeEach
    void setUp() {
        businessService = new BusinessService();
    }

    @Test
    void findAll_shouldReturnInitialMockData() {
        List<BusinessItem> items = businessService.findAll();
        assertEquals(3, items.size());
    }

    @Test
    void findById_shouldReturnItemWhenExists() {
        Optional<BusinessItem> result = businessService.findById(1L);
        assertTrue(result.isPresent());
        assertEquals("项目Alpha", result.get().getName());
    }

    @Test
    void findById_shouldReturnEmptyWhenNotExists() {
        Optional<BusinessItem> result = businessService.findById(999L);
        assertFalse(result.isPresent());
    }

    @Test
    void save_shouldAssignIdAndStoreItem() {
        BusinessItem newItem = new BusinessItem(null, "新项目", "新项目描述");
        BusinessItem saved = businessService.save(newItem);

        assertNotNull(saved.getId());
        assertEquals("新项目", saved.getName());

        Optional<BusinessItem> found = businessService.findById(saved.getId());
        assertTrue(found.isPresent());
        assertEquals("新项目描述", found.get().getDescription());
    }
}


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/README.md


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/src/main/java/com/example/demo/DemoApplication.java


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/src/main/java/com/example/demo/model/BusinessItem.java


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/src/main/java/com/example/demo/service/BusinessService.java


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/src/main/java/com/example/demo/controller/HealthController.java


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/src/main/java/com/example/demo/controller/BusinessController.java


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/src/main/java/com/example/demo/config/OpenApiConfig.java


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/src/main/resources/application.yml


已写入文件：codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/src/test/java/com/example/demo/BusinessServiceTest.java


status


type


coding


已完成


Java


工程


代码


生成


所有


文件


已


写入


code


gen


-r


uns


/c


ode


e


c


a


f


d


目录


共


生成


个


文件


p


om


.xml


README


.md


Demo


Application


.java


Business


Item


Service


Health


Controller


Open


Api


Config


application


.yml


Test


status


result


type


summary


生成


文件


清单


序号


路径


说明


p


om


.xml


M


aven


项目


配置


Spring


Boot


Java


Kn


ife


j


README


.md


文档


src


/main


/java


/com


example


/d


emo


/D


Application


.java


Spring


Boot


启动


入口


/model


/B


usiness


Item


业务


数据


模型


含


Sw


agger


注解


src


/main


/java


/com


example


/d


emo


/service


/B


usiness


Service


.java


业务


服务


层


基于


内存


Concurrent


HashMap


假


数据


预留


数据库


扩展


点


src


/main


/java


/com


example


/d


emo


controller


Health


Controller


.java


健康


检查


接口


GET


api


health


src


/main


/java


/com


example


/d


emo


controller


/B


usiness


Controller


.java


业务


CR


UD


接口


GET


/P


OST


api


/b


items


src


/main


/java


/com


example


/d


emo


/config


Open


Api


Config


.java


API


/S


w


agger


配置


类


src


/main


/resources


application


.yml


应用


配置文件


端口


Kn


ife


j


启用


/test


/java


/com


example


/d


emo


/B


usiness


Service


Test


.java


业务


服务


单元


测试


个


用例


启动


方式


bash


方法


一


直接


M


aven


cd


code


gen


-r


uns


/c


ode


e


c


a


f


d


m


vn


spring


-b


oot


run


方法


二


打包


后


运行


package


D


skip


Tests


java


jar


target


/d


emo


.jar


测试


m


vn


test


接口


文档


访问


地址


启动


后


以下


Kn


ife


j


UI


推荐


http


localhost


/doc


.html


Sw


agger


/sw


-ui


Open


API


JSON


/v


/api


-d


ocs


提供的


接口


方法


路径


说明


GET


api


health


健康


检查


返回


服务


状态


和时间


戳


/b


usiness


items


获取


所有


业务


数据


内存


假


默认


条


GET


api


id


根据


ID


单


POST


/b


usiness


items


新增


业务


数据


工程


特点


纯


内存


运行


无


数据库


Redis


MQ


等


外部


依赖


开


箱


即


用


接口


文档


完整


集成


Kn


ife


j


Sw


agger


所有


和


模型


均有


中文


描述


可


编译


测试


m


vn


test


运行


个


单元


用例


预留


扩展


点


Business


Service


使用


Concurrent


HashMap


实现


后续


可


替换


为


Repository


数据库


代码


简洁


精


炼


仅


包含


必要


组件


无


冗余


result


已完成 Java 工程代码生成，所有文件已写入 codegen-runs/codegen_4e0144659c074910a41688c05f7d7053/ 目录。
共生成 10 个文件：pom.xml、README.md、DemoApplication.java、BusinessItem.java、BusinessService.java、HealthController.java、BusinessController.java、OpenApiConfig.java、application.yml、BusinessServiceTest.java。


## 生成文件清单

| 序号 | 文件路径 | 说明 |
|------|---------|------|
| 1 | `pom.xml` | Maven 项目配置，Spring Boot 3.2.5 + Java 17 + Knife4j 4.5.0 |
| 2 | `README.md` | 项目说明文档 |
| 3 | `src/main/java/com/example/demo/DemoApplication.java` | Spring Boot 启动入口 |
| 4 | `src/main/java/com/example/demo/model/BusinessItem.java` | 业务数据模型（含 Swagger 注解） |
| 5 | `src/main/java/com/example/demo/service/BusinessService.java` | 业务服务层（基于内存 ConcurrentHashMap 假数据，预留数据库扩展点） |
| 6 | `src/main/java/com/example/demo/controller/HealthController.java` | 健康检查接口 GET /api/health |
| 7 | `src/main/java/com/example/demo/controller/BusinessController.java` | 业务 CRUD 接口（GET/POST /api/business/items） |
| 8 | `src/main/java/com/example/demo/config/OpenApiConfig.java` | OpenAPI/Swagger 配置类 |
| 9 | `src/main/resources/application.yml` | 应用配置文件（端口 8080，Knife4j 启用） |
| 10 | `src/test/java/com/example/demo/BusinessServiceTest.java` | 业务服务单元测试（4 个测试用例） |

## 启动方式

```bash
# 方法一：直接 Maven 启动
cd codegen-runs/codegen_4e0144659c074910a41688c05f7d7053
mvn spring-boot:run

# 方法二：打包后运行
mvn package -DskipTests
java -jar target/demo-1.0.0.jar

# 运行测试
mvn test
```

## 接口文档访问地址

启动后访问以下地址：

- **Knife4j UI（推荐）**: http://localhost:8080/doc.html
- **Swagger UI**: http://localhost:8080/swagger-ui.html
- **OpenAPI JSON**: http://localhost:8080/v3/api-docs

## 提供的接口

| 方法 | 路径 | 说明 |
|------|------|------|
| GET | `/api/health` | 健康检查，返回服务状态和时间戳 |
| GET | `/api/business/items` | 获取所有业务数据（内存假数据，默认 3 条） |
| GET | `/api/business/items/{id}` | 根据 ID 获取单条业务数据 |
| POST | `/api/business/items` | 新增业务数据 |

## 工程特点

- ✅ **纯内存运行**：无数据库、Redis、MQ 等外部依赖，开箱即用
- ✅ **接口文档完整**：集成 Knife4j + Swagger，所有接口和模型均有中文描述
- ✅ **可编译可测试**：`mvn test` 可运行 4 个单元测试用例
- ✅ **预留扩展点**：BusinessService 使用 ConcurrentHashMap 实现，后续可替换为 Repository + 数据库实现
- ✅ **代码简洁精炼**：仅包含必要组件，无冗余代码


# 方法一：直接 Maven 启动
cd codegen-runs/codegen_4e0144659c074910a41688c05f7d7053
mvn spring-boot:run

# 方法二：打包后运行
mvn package -DskipTests
java -jar target/demo-1.0.0.jar

# 运行测试
mvn test


end