Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

"Advanced articles" docker Development user Service (12)

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Original articles, welcome to reprint. Reprint please indicate: reproduced from IT Story Association, thank you!

Original link address: "Advanced article" docker development user service (12)

In this section, we begin to develop user services, and the last information service developed through python has been developed. Source code: https://github.com/limingios/msA-docker

Analysis of user service

User services are developed in thift language and rely on the following information services through Java interfaces. There is a database at the back end. To develop a service, you need to design external interfaces and what kind of services are provided to others.

User service interface creation

Pom editor

Ms-server com.idig8 1.0-SNAPSHOT4.0.0com.idig8user-thrift-service-api1.0-SNAPSHOT org.apache.thrift libthrift 0.10.0 org.apache.maven.plugins maven-compiler-plugin 2.3.2 1.8 1.8

* create thrift ```thriftnamespace java com.idig8.thrift.userstruct UserInfo {1:i32 id, 2:string username, 3:string password, 4:string realName, 5:string mobile, 6:string email} service UserService {UserInfo getUserById (1:i32 id) UserInfo getUserByName (1:string username); void regiserUser (1:UserInfo userInfo);}

Command to generate the interface class thrift corresponding to java-- gen java-out.. / src/main/java user-service.thrift

Without establishing the environment variable, it is generated directly under the directory, and then copied to the corresponding directory.

Generate 2 classes, one is the entity class, and the other is the corresponding user-service (all generated automatically through thrift). Because there is too much source code generated automatically, please download it directly from the link address of the article header.

Implement the interface of user-thrift-serive-api

It is recommended that you use docker to install mysql. Before, I used to install docker in windows and mac environments. Under # mac, cur_dir = 'pwd'docker stop idig8-mysqldocker rm idig8-mysqldocker run-- name idig8-mysql-v ${cur_dir} / conf:/etc/mysql/conf.d-v ${cur_dir} / data:/var/lib/mysql-p 3306-e MY_ROOT_PASSWORD=root-d mysql:latest

Here I directly use an ip address of the public network to remotely access and create a new database table.

The way user-thrift-service uses springboot

These are the basic operations of springboot, it is recommended to look at my source code.

PS: old man may feel very confused, let me talk about the train of thought from beginning to end

Write a thrift file to establish an api interface, that is, user-thrift-service-api, generate the corresponding java class through thrift to establish user-thrift-service, and reference user-thrift-service-api 's jar package file through pom. Set up service in user-thrift-service and implement the jar package interface method of user-thrift-service-api. Through the introduction of mybatise, the database is called dao,service and dao is introduced, the interface method introduced by the interface ThriftServer is completed, the service code is started, and the port configuration in RPC activation properties is realized.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report