Thrift Project Server-side development process
First, understand the functionality of all packages in the project (see)
The diagram is the directory structure of the User Center project, which is described in turn below.
- 1. Src/main/java
Com.framework: This directory holds some of the common classes required for all systems.
Com.user: This package is under the function code of this group.
DAO: This layer mainly holds the method of invoking the database layer
Entity: Business entity Bean
Mapper: Business SQL
Implementation class for the Service:thrift interface
Thrift:thrift IDL-generated Java files
Com.utoken.table: This store mybatis the Mapper and DAO required for single-table operation, and can operate quickly on a single table.
- 2. src/main/resources
Config: Storage package for configuration files
LOG: Store log4j configuration file
MyBatis: Here is the configuration file for MyBatis
Configuration file for spring:spring
System:applicationcontext configuration file
Thrift:thrift client and server-side configuration files
Thrift-idl: Storing the Thrift IDL file, which is not useful in the system, but facilitates the developer to quickly understand the definition specification of the interface.
- 3. Web-inf
Store Logs,web.xml and Proxool.xml (the file cannot be found at compile time under Config, so it can only be placed here).
At this point, the directory structure of the project is complete.
The development process is divided into two ways: simple single-table operation and complex operation.
Note: The single-table operation can be used as far as possible to achieve the implementation of single table, improve development efficiency.
Simple single-table operation specific process:
A single table operation can be implemented directly using the single-table operation class generated by MyBatis, with the following details:
For a single-table operation, you can quickly complete a single table operation by adding only two of the contents of the red circle.
Lineaskserviceimpl: This class is the implementation of the Lineaskservice interface and is also the main function module.
The simple process of the entire single-table operation has been briefly described.
Complex Operating Procedures:
The red area is a required file, which is created in the corresponding way, with the class name Convention rule: The service name is added to the corresponding package name.
The features of each file are not described here, the Spring framework is based on the relevant documentation.
- The contents of DAO are as follows:
The contents of 2.Mapper are as follows:
3.Entity content is no longer described in detail, see
4. Authoring of interface Implementation classes
After the operation of the above step, you can perform service configuration work.
Configure Thrift-service.xml
There is a new interface that adds a new service interface bean to the red zone, sequentially adding the bean to the thriftserverlist. After the operation of the above step, you can publish the service.
Thrift Project Server-side development process