A Java annotation processor for entity persistence using Spring, using the idea to generate Java code in the compilation time, with CX annotation you will be enabled to create a REST API just annotation simple Java classes, create full APIs without adding new heavy frameworks and using a very straightforward approach
With a class like this, using the CX annotations, the annotation processor will generate a full CRUD RESTful service
that be can accesed through <host_url>:<server.port>/CX/{custom-path-for-cx-entity}
with GET
, POST
, PUT
, DELETE
HTTP requests!
Features:
- Repository, Service, Controller layers auto-generated
- Auto table creation
- Using REST standard for API's
- JSON response for auto generated controllers
- Configurable database connection using JDBC
- Custom API base path
- Database table creation by CX entities
- Full CRUD actions by CX entity definition
package com.javatpoint;
import dev.tools.annotationprocessor.core.annotations.CXSpringRestCrudApi;
import dev.tools.annotationprocessor.core.annotations.entity.CXColumn;
import dev.tools.annotationprocessor.core.annotations.entity.CXEntity;
import dev.tools.annotationprocessor.core.annotations.entity.CXId;
import dev.tools.annotationprocessor.core.annotations.entity.types.column.BigInt;
import dev.tools.annotationprocessor.core.annotations.entity.types.column.Int;
import dev.tools.annotationprocessor.core.annotations.entity.types.column.Varchar;
import lombok.Data;
/**
* CX API entity handling generated by CX Annotation Processor
* @author josuerv99
*/
@Data
@CXSpringRestCrudApi(path = "/message")
@CXEntity(tableName = "message_demo_01")
public class Message {
@CXId(generated = true)
@CXColumn(name = "ID")
@BigInt
private Long id;
@CXColumn(name = "CONTENT")
@Varchar
private String content;
@CXColumn(name = "FROM_CONTACT_NAME")
@Varchar(length = 200)
private String from;
@CXColumn(name = "TO_CONTACT_NAME")
@Varchar(length = 199)
private String to;
@CXColumn(name = "READERS_COUNTER")
@Int
private Integer readBy;
}