当前位置:网站首页>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
边栏推荐
- rxjs Observable 自定义 Operator 的开发技巧
- selenium 元素定位方法
- 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
- 抓包工具fiddler学习
- MySQL45讲——学习极客时间MySQL实战45讲笔记—— 05 | 深入浅出索引(下)
- 给Android程序员的一些面试建议「建议收藏」
- Three talking about exception -- error handling
- P1347 sorting (topology + SPFA judgment ring or topology [inner judgment ring])
- [template] longest common subsequence ([DP or greedy] board)
- 每天坚持20分钟go的基础二
猜你喜欢
Qt-制作一个简单的计算器-实现四则运算-将结果以对话框的形式弹出来
c# 水晶报表打印
Selenium installing selenium in pycharm
qt中uic的使用
Codeforces Round #803 (Div. 2)(A~D)
Will your sleep service dream of the extra bookinfo on the service network
Default slot, named slot, scope slot
Sum of the first n terms of Fibonacci (fast power of matrix)
万物生长大会在杭召开,当贝入选2022中国未来独角兽TOP100榜单
Don't spend money, spend an hour to build your own blog website
随机推荐
Story point vs. Human Sky
693. 行程排序(map + 拓扑)
[template] longest common subsequence ([DP or greedy] board)
D language, possible 'string plug-ins'
How to use SAP's metadata framework (MDF) to build custom business rules?
全屋Wi-Fi:一个谁也解决不好的痛点?
Qt原代码基本知识
P1347 sorting (topology + SPFA judgment ring or topology [inner judgment ring])
P3008 [usaco11jan]roads and planes g (SPFA + SLF optimization)
Everyone believes that the one-stop credit platform makes the credit scenario "useful"
Browser driven Download
Word frequency statistics & sorting
P3008 [USACO11JAN]Roads and Planes G (SPFA + SLF优化)
Origin plots thermogravimetric TG and differential thermogravimetric DTG curves
数据湖(十一):Iceberg表数据组织与查询
Pattern matching and regular expressions in PostgreSQL - Das
mysql ---- Oracle中的rownum转换成MySQL
故事点 vs. 人天
Data consistency between redis and database
Halcon extract orange (Orange)