当前位置:网站首页>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}/bin
Maven-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}/bin
git
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 how to set fixed size
- 不会看器件手册的工程师不是个好厨子
- Quantum three body problem: Landau fall
- How to set QT manual layout
- Don't spend money, spend an hour to build your own blog website
- QT new project_ MyNotepad++
- Explanation: here is your UFO, Goldbach conjecture
- 千元投影小明Q1 Pro和极米NEW Play谁更好?和哈趣K1比哪款配置更高?
- 路由(二)
- selenium 元素定位方法
猜你喜欢
不会看器件手册的工程师不是个好厨子
Common options of tcpdump command: Three
Selenium element positioning method
Skillfully use SSH to get through the Internet restrictions
Design of non main lamp: how to make intelligent lighting more "intelligent"?
Whole house Wi Fi: a pain point that no one can solve?
Just 1000 fans, record it
How to explain binary search to my sister? This is really difficult, fan!
selenium,元素操作以及浏览器操作方法
混沌工程平台 ChaosBlade-Box 新版重磅发布
随机推荐
OpenFOAM:lduMatrix&lduAddressing
Sum of the first n terms of Fibonacci (fast power of matrix)
Launcher startup process
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
[USACO05JAN]Watchcow S(欧拉回路)
[technology development-22]: rapid overview of the application and development of network and communication technology-2-communication Technology
Do you know that there is an upper limit on the size of Oracle data files?
Dingtalk send message
P1347 sorting (topology + SPFA judgment ring or topology [inner judgment ring])
ensp简单入门
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
Will your sleep service dream of the extra bookinfo on the service network
693. 行程排序(map + 拓扑)
2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验
P1908 reverse sequence pair
MySQL45讲——学习极客时间MySQL实战45讲笔记—— 04 | 深入浅出索引(上)
Development skills of rxjs observable custom operator
Systemserver process
Android kotlin fragment technology point
Dangbei projection 4K laser projection X3 Pro received unanimous praise: 10000 yuan projector preferred