当前位置:网站首页>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
边栏推荐
- qt中uic的使用
- Route (II)
- Dangbei projection 4K laser projection X3 Pro received unanimous praise: 10000 yuan projector preferred
- Integral link, inertia link and proportion link in Simulink
- Daily practice of C language --- monkeys divide peaches
- In 2021, the global styrene butadiene styrene (SBS) revenue was about $3722.7 million, and it is expected to reach $5679.6 million in 2028
- Halcon extract orange (Orange)
- 如何设置Qt手工布局
- MySQL 45 lecture - learning from the actual battle of geek time MySQL 45 Lecture Notes - 04 | easy to understand index (Part 1)
- 无主灯设计:如何让智能照明更加「智能」?
猜你喜欢
随机推荐
c# 水晶报表打印
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
Qt-制作一个简单的计算器-实现四则运算
当贝投影4K激光投影X3 Pro获得一致好评:万元投影仪首选
Design of non main lamp: how to make intelligent lighting more "intelligent"?
路由(二)
D language, possible 'string plug-ins'
Golang 快速生成数据库表的 model 和 queryset
P3807 [template] Lucas theorem /lucas theorem
你知道Oracle的数据文件大小有上限么?
联合搜索:搜索中的所有需求
Story points vs. human days
Origin plots thermogravimetric TG and differential thermogravimetric DTG curves
qt中uic的使用
Codeforces Round #803 (Div. 2)(A~D)
Use of UIC in QT
Memory management 01 - link script
ensp简单入门
Launcher startup process
你的 Sleep 服务会梦到服务网格外的 bookinfo 吗








