当前位置:网站首页>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
边栏推荐
- Sum of the first n terms of Fibonacci (fast power of matrix)
- Do you know that there is an upper limit on the size of Oracle data files?
- 瀏覽器驅動的下載
- Solve "sub number integer", "jump happily", "turn on the light"
- Android kotlin fragment technology point
- P1347 sorting (topology + SPFA judgment ring or topology [inner judgment ring])
- Word frequency statistics & sorting
- (POJ - 1308)Is It A Tree? (tree)
- Selenium, element operation and browser operation methods
- selenium 在pycharm中安装selenium
猜你喜欢

Runhe hi3516 development board openharmony small system and standard system burning

Everyone believes that the one-stop credit platform makes the credit scenario "useful"

Default slot, named slot, scope slot

千元投影小明Q1 Pro和极米NEW Play谁更好?和哈趣K1比哪款配置更高?

你知道Oracle的数据文件大小有上限么?

当贝投影4K激光投影X3 Pro获得一致好评:万元投影仪首选

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

大家信夫一站式信用平台让信用场景“用起来

Qt新项目_MyNotepad++

Do you know that there is an upper limit on the size of Oracle data files?
随机推荐
Halcon extract orange (Orange)
Mysql5.7 installation super easy tutorial
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
Golang 快速生成数据库表的 model 和 queryset
石子合并板子【区间DP】(普通石子合并 & 环形石子合并)
代码实现MNLM
(POJ - 1984) navigation nightare (weighted and search set)
Error: eacces: permission denied, access to "/usr/lib/node_modules"
Selenium element positioning method
Solve "sub number integer", "jump happily", "turn on the light"
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
当贝投影4K激光投影X3 Pro获得一致好评:万元投影仪首选
qt中uic的使用
Integral link, inertia link and proportion link in Simulink
Gee learning notes 2
Will your sleep service dream of the extra bookinfo on the service network
Astro learning notes
Three talking about exception -- error handling
Word frequency statistics & sorting
你知道Oracle的数据文件大小有上限么?