docs / guides/componentsspring-cli

Generate components ​

Run component commands from a generated project. spring-cli locates the project config from the current directory or one of its parents.

Add one component ​

bash
spring-cli add controller --name Product
spring-cli add service --name Product

Supported component kinds are controller, service, repository, entity, dto, config, listener, and exception. If --name is omitted, the CLI prompts for a name.

OptionDescription
-n, --name <name>Logical component name.
-f, --forceOverwrite the generated file if it already exists.

Names are converted to Java class names and component-specific suffixes are appended. For example, product generates ProductController, ProductService, or ProductRepository. Controllers also receive a kebab-case @RequestMapping, such as /product.

The templates provide a class and relevant Spring annotation where applicable. They do not implement business logic, repository persistence, or CRUD behavior for you.

Scaffold a CRUD set ​

bash
spring-cli scaffold product

scaffold creates five files for the resource: entity, DTO, repository, service, and controller. Use --name to choose a different logical name, and --force to overwrite existing generated files:

bash
spring-cli scaffold product --name CatalogItem --force

scaffold creates starter classes; it does not generate CRUD methods or connect the classes together.

Make JPA entities from a schema ​

For table mappings, fields, and relationships, use schema apply instead of the plain entity skeleton from add or scaffold.