当前位置:网站首页>Quarkus learning IV - project development to deployment
Quarkus learning IV - project development to deployment
2022-07-02 14:07:00 【eeaters】
- Write it at the front
- Project background
- Responsive and imperative choices
- Development related
- Database configuration
- reactive-panache Operating the database < Persistence 、 Check multiple tables >
- How to use the self increment of the primary key and the default value of the field
- Deployment related ( Tencent cloud )
- JDK-18
- Maven-3.8.6
- git
- Project start
- A firewall
Write it at the front
Project background
In writing graduation project , The original intention is to learn quarkus frame , By the way, learn a front-end framework ( Not yet front-end )
But the reality is :
The teacher said to show him the function in a week . I was stunned in an instant : The back-end frame is now learning , The front end won't . Review the html+css+js Started writing projects , Here we will mainly use quarkus And project deployment ( Not docker) Sort it out
Responsive and imperative choices
- master Branch : imperative
- reactive_mode Branch : Response type
After the basic functions are developed with responsiveness , When the page click frequency is high
- Front end error reporting : Provisional headers are shown
- Back end error : io.vertx.core.impl.NoStackTraceThrowable
May use improper posture , But according to the code written on the official website, there are more or less quarkus Of reactive Unstable factors . Therefore, it is changed to imperative programming mode later . You have to hand in your homework , There is no time to waste …
Development related
Database configuration
There is a little pit here ,reactive And imperative mode , The values of database configuration key value pairs are different
- reactive: mysql://127.0.0.1:3306/test
- imperative : jdbc:mysql://127.0.0.1:3306/test
reactive-panache Operating the database < Persistence 、 Check multiple tables >
Persistence example :
@POST
@Path("/create")
@Blocking
public Uni<BaseResponse<Long>> create(ChannelAccount channelAccount) {
// You need to call flush after , In order to return to id, pure persist It can be saved correctly but cannot return self incrementing id
Uni<ChannelAccount> persist = channelAccount.persistAndFlush();
return persist.onItem()
.transform(account -> account.getId())
.onItem()
.transform(BaseResponse::success);
}Multi table result set returns :
@GET
@Produces(MediaType.TEXT_HTML)
@Blocking
public Uni<TemplateInstance> store(@QueryParam("name") String name) {
Uni<List<Store>> storeListUni = Store.findAll().list();
List<Store> storeList = storeListUni.await().indefinitely();
Uni<List<DeliveryStrategy>> strategyListUni = DeliveryStrategy.findAll().list();
List<DeliveryStrategy> strategyList = strategyListUni.await().indefinitely();
return Uni.createFrom()
.item(() -> {
TemplateInstance instance = store.data("storeList", storeList)
.data("strategyList", strategyList)
.data("name", name);
return instance;
});
}How to use the self increment of the primary key and the default value of the field
public class ChannelAccount extends PanacheEntityBase {
//`id` bigint(20) NOT NULL AUTO_INCREMENT,
//PRIMARY KEY (`id`)
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
//`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT ' Creation time ',
@Column(name = "create_time", insertable = false, updatable = false)
private LocalDateTime createTime;
// `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ' Update time ',
@Column(name = "update_time", insertable = false, updatable = false)
private LocalDateTime updateTime;
}Deployment related ( Tencent cloud )
JDK-18
use wget Installation ;
step | function |
|---|---|
1. download tar package | wget jdk Official tar.gz package |
decompression | tar -zxvf tar.gz |
Configure environment variables | vi /etc/profile |
Configuration takes effect | source /etc/profile |
test | java -version |
export JAVA_HOME=/usr/java/jdk-18.0.1.1
export CLASSPATH=${JAVA_HOME}/lib:$CLASSPATH
export PATH=$PATH:${JAVA_HOME}/binMaven-3.8.6
maven Same operation wget Command to install
step | function |
|---|---|
download tar package | wget maven Official tar.gz package |
decompression | tar -zxvf apache-maven-3.8.6-bin.tar.gz |
Configure environment variables | modify /etc/profile file , Add environment variables |
Configuration takes effect | source /etc/profile |
View version | mvn -v |
export MAVEN_HOME=/usr/maven/apache-maven-3.8.6
export PATH=$PATH:${MAVEN_HOME}/bingit
sudo apt-get install git
As a server , If you can pull the code , So we use https Agreement to use git Command the project clone
Project start
cd To the project directory
mvn quarkus:dev This belongs to the development mode , The effect of implementation is no effect , Because this external cannot be accessed , The right posture is :
- mvn clean package -U -Dquarkus.package.type=uber-jar
- nohup java -jar target/{project}.jar
- uber: It refers to packaging the project and its dependencies
- nobup: It refers to making the project run in the background , direct java -jar Once the interface is closed, the service disappears
A firewall
The port number will be exposed in the settings of ECS
At this time, you can correctly access the project on the Internet
边栏推荐
- 每天坚持20分钟go的基础二
- 全屋Wi-Fi:一个谁也解决不好的痛点?
- 大家信夫一站式信用平台让信用场景“用起来
- Android kotlin fragment technology point
- rxjs Observable 自定义 Operator 的开发技巧
- BeanUtils -- shallow copy -- example / principle
- Dangbei projection 4K laser projection X3 Pro received unanimous praise: 10000 yuan projector preferred
- 无主灯设计:如何让智能照明更加「智能」?
- Launcher启动过程
- Android kotlin broadcast technology point
猜你喜欢

Explanation: here is your UFO, Goldbach conjecture

Codeforces Round #803 (Div. 2)(A~D)

C crystal report printing

Qt新项目_MyNotepad++

The conference on the growth of all things was held in Hangzhou, and dangbei was selected into the top 100 list of future unicorns in China in 2022

Who is better, Qianyuan projection Xiaoming Q1 pro or Jimi new play? Which configuration is higher than haqu K1?

How to explain binary search to my sister? This is really difficult, fan!

Custom events, global event bus, message subscription and publishing, $nexttick

MySQL45讲——学习极客时间MySQL实战45讲笔记—— 05 | 深入浅出索引(下)

PyQt5_QScrollArea内容保存成图片
随机推荐
Winter vacation daily question - lucky numbers in the matrix
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
Explanation: here is your UFO, Goldbach conjecture
(POJ - 1308)Is It A Tree? (tree)
Daily practice of C language --- monkeys divide peaches
selenium的特点
SystemServer进程
Android kotlin fragment technology point
(POJ - 1984) navigation nightare (weighted and search set)
代码实现MNLM
The xftp connection Haikang camera reported an error: the SFTP subsystem application has been rejected. Please ensure that the SFTP subsystem settings of the SSH connection are valid
Solution: Compression Technology (original version and sequel version)
一般来讲,如果频繁出现inconsistent tab and space的报错
Sum of the first n terms of Fibonacci (fast power of matrix)
Whole house Wi Fi: a pain point that no one can solve?
Code implementation MNLM
Selenium installing selenium in pycharm
uniapp小程序 subPackages分包配置
Data consistency between redis and database
Add sequence number column to query results in MySQL