Spring framework study notes (6) - Ali cloud server deployment Spring Boot project (jar package)

Recently received outsourcing, need to deploy server, is an online reference of several blog posts, Ali cloud server successfully in the successful deployment of the Spring Boot projects, special note of Benpian notes

Spring Boot project package

Here to talk about some of the issues of deployment

1.mysql drive

Create a spring boot when the interface select Add dependence MySql, however, when the actual project tested and found driver error, therefore, you have to be changed following MySql driven drive

<!-- mysql驱动 -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>

2. Package

Use spring boot project, quickly hit maven jar package through the lifecycle of the package, this jar package built tomcat server, then you can run the jar packets directly.

Then we can get a jar package, to deploy this jar package to the server

Configuring pagoda linux environment

Buy server

I purchased a student host, relatively affordable, as long as the real-name verification is the result of 24 years of age, student status is automatically the default
choice lightweight application server and linux pagoda options, you can quickly install and use linux pagoda panel, it is suitable not know linux command of the crowd

System installation pagoda

First of all, after purchasing the server will ask you to set the administrator password, and then connect to a remote server, switch to an administrator account, enter the following command to install linux pagoda

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh

After a prompt will pop up, and then enter y to start the installation

We enter the following command to view the pagoda linux system system-generated username and password

/etc/init.d/bt default

Login pagoda linux system

Pagoda address ip address: 8888, as47.22.22.33:8888

Use account password system obtained above pagoda pagoda login linux system, followed by the installation environment (database, php, tomcat)

Since we are deployed jar package, so you need to configure the server environment is good java, java environment we do not want to configure via the command line type, you can choose to install Tomcat environment pagoda system

Install Tomcat Java environment will be installed by default the environment, Tomcat environment, then select the version 8, so that the default Java environment is 1.8, if version 7, the default environment for Java 1.7

Remote connection server

You can use ssh local client server remote connection, I used here is xshell, the connection is very simple, only need to configure the host (Ip address), user name and password

After entering the administrator password can be successfully landed in linux

Mysql database server configuration

1. Turn on the 3306 release Interface

PS: you may also need to add firewall rules on the server

2. Configure mysql remote connection

The default is to not allow remote connections mysql, so we have to configure the remote connection mysql

Using ssh Xshell other clients, remote connection to the server, then enter the command mysql -u 账户名 -pto enter the password after mysql command line, enter the following command

%使用mysql默认的数据库
use mysql;
%设置远程连接
update user set host ='%' where user = 'root' and host='localhost';
%刷新
flush privileges

Reference links:

Mysql root password initialization and allow remote access

Navicat MySQL remote connections appear to solve 10060 unknow error

Deployment Project

Spring boot server deployment project in two ways, war (tomcat traditional way), jar

war of words, directly on to the tomcat webapp directory

As used herein, is a jar package deployment, use linux pagoda that spring boot the system before the jar package uploaded to the server

Because it is a server, if you turn off the remote connection window, it will automatically end of the process, therefore, we have to realize running in the background jar package

Use the command to turn back

//远程连接关闭,也会关闭
java -jar xx.jar
//后台
java -jar xx.jar &

Create a new script start.sh, then the script needs to be given permission (pagoda linux file options can quickly change)

java -jar xx.jar >nohup.out 2>&1& 

The script above, only need to modify the package to the correct jar file, after executing the script will open the background jar package, meanwhile, will log output to a file nohup.out

We built in the local script, and then uploaded to the server, modify the permissions to 777

The following full-checked, the authority will become 777

After passing through ssh client remote connection to the server, as an administrator to execute the script

./start.sh

After the visit, then the project is through ip地址+端口号+项目名, such as 44.22.22.22:13888/Demo/hello, here, I was in spring boot configuration file to customize the port 13888, the default is 8080 words

If you have custom port, but also the release of port security options can be modified in the pagoda linux system, please refer to the above mysql release port

If the project is subject to change once again when deployed, first check by jps command to run jar package, after closing process, re-upload a new jar package, and you can execute the script

Guess you like

Origin www.cnblogs.com/kexing/p/11785415.html