阿里云通用代金卷活動(dòng)(土豪購(gòu)買可忽略)
購(gòu)買前領(lǐng)取幸運(yùn)券,可能會(huì)有折上折優(yōu)惠哦:領(lǐng)取幸運(yùn)抵扣卷
購(gòu)買地址
win10直接連接阿里云服務(wù)器(Linux):
【如果使用XShell可以跳過(guò)】
- 首先你得安裝下telnet客戶端,系統(tǒng)自帶的。
控制面板——程序與功能——啟動(dòng)或關(guān)閉windows功能
QQ截圖20191125143655.png
2.將Telnet客戶端勾上,點(diǎn)確定(等待安裝完成即可)。
QQ圖片20191125144043.png
3.win鍵+R鍵 然后輸入CMD 回車打開CMD窗口
輸入 ssh 賬號(hào)名@服務(wù)器ip地址:端口號(hào)
例如:ssh root@111.222.1.2
第一次可能需要輸入yes,如果輸了no就無(wú)法連接了
然后再讓你輸入密碼(輸入密碼時(shí),你是看不出有任何變化的【因?yàn)長(zhǎng)inux覺得“沒有消息就是最好的消息??”】)
QQ截圖20191125144557.png
XShell、XFtp的安裝與使用


XShell使用(連接XFtp和連接XShell一樣):
新建一個(gè)會(huì)話

點(diǎn)擊你新建的回話,彈出讓你輸入用戶名(一般默認(rèn)用戶名為root)

點(diǎn)擊確認(rèn)后就會(huì)讓你輸入密碼(可以在阿里云官網(wǎng)重置修改)

這樣你就連接上服務(wù)器了。
Linux添加用戶(可以根據(jù)不用用戶給不同權(quán)限)
登錄root賬號(hào)后
輸入:useradd -d /usr/zxy -m zxy2019
-d 是給新用戶創(chuàng)建主目錄
-m 是用戶名-
修改新用戶的密碼(修改前我們先進(jìn)到新用戶的主目錄)
輸入:cd /usr/zxy/
輸入:passwd zxy2019
輸入:你的新密碼
輸入:確認(rèn)新密碼
QQ圖片20191125161154.png -
給予權(quán)限
輸入:sudo vim /etc/sudoers
QQ圖片20191125161958.png
輸入:/root(可以快速定位root 位子,然后再添加自己新用戶的權(quán)限,相匹配的會(huì)出現(xiàn)高亮)
輸入::noh(取消高亮)
輸入:i(即可寫了)
輸入::wq!(強(qiáng)制保存)
JDK的安裝與配置
這里需要注意下:
我們平常linux 下載jdk都會(huì) wget http://xxxxxx 這種方式,現(xiàn)在由于oracle限制了,每次下載的安裝包都是沒用的,解壓失敗問(wèn)題(既然下載不了,那我們就本地下載上傳上去)
所以我們使用XShell和XFT來(lái)進(jìn)行云服務(wù)器的控制和文件的傳輸(非商業(yè)用途的免費(fèi)使用)
-
檢查是否安裝
輸入:rpm -qa| grep jdk(什么信息都沒返回就說(shuō)明沒安裝)
QQ截圖20191125174044.png 下載:java下載地址
下載對(duì)應(yīng)版本的包(后綴為:.tar.gz)
sudo mkdir java(一般會(huì)再根目錄下新建一個(gè)文件夾)-
上傳到服務(wù)器(直接拖進(jìn)去就行)
QQ截圖20191126112053.png -
解壓
tar -zxvf jdk-8u181-linux-x64.tar.gz(沒任何提示就說(shuō)明成功了,或者你也可以打開XFT查看)
QQ截圖20191126113049.png 配置環(huán)境變量(配置之前,建議先給系統(tǒng)來(lái)個(gè)快照。不然你profile文件修改錯(cuò)誤后你會(huì)頭大??各種指令失效)
輸入:vim /etc/profile(打開profile文件夾)
輸入:i(插入命令)
輸入:
export JAVA_HOME=/java/jdk1.8.0_231
export JRE_HOME=/java/jdk1.8.0_231/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin/$JAVA_HOME:$PATH

(輸入完成后,按下esc鍵退出輸入)
輸入:
:wq! (強(qiáng)制保存)輸入:
source /etc/profile(使環(huán)境變量生效 )輸入:
java –version命令和javac(檢測(cè)是否配置成功)使用javac命令,不會(huì)出現(xiàn)command not found錯(cuò)誤
使用java -version,出現(xiàn)版本為java version "1.8.0_231"

安裝tomcat及配置環(huán)境
1.下載:Tomcat下載地址(這里我們還是和java一樣去官網(wǎng)下載)

- 上傳到服務(wù)器(直接拖進(jìn)去就行)
- 解壓
tar -zxvf apache-tomcat-9.0.29.tar.gz - 重命名:
mv apache-tomcat-9.0.29 tomcat9(為方便記憶以及日后的使用,也可以不從命名) - 配置字符集
vim conf/server.xml(把端口改成80,或者其他你想要的端口)
QQ截圖20191126220630.png
6.在tomcat/bin 目錄下輸入:./startup.sh(啟動(dòng)tomcat)
QQ圖片20191126221822.png
6-1 在本地測(cè)試下是否開啟成功
輸入:curl localhost:80出現(xiàn)html網(wǎng)頁(yè)源碼就說(shuō)明啟動(dòng)成功。
QQ截圖20200203231631.png
-
在瀏覽器輸入公網(wǎng)ip:端口號(hào) 就可以看到tomcat的網(wǎng)址,證明配置成功(然而你可能還是訪問(wèn)不到??看上去都很簡(jiǎn)單,但是自己一操作就各種問(wèn)題??。跑題了,咱們繼續(xù)...)
QQ截圖20191128225435.png
QQ截圖20191128225627.png - 確認(rèn)你安全組里面允許了該端口(這里你允許了可能還是沒用??)
- 再次去設(shè)置tomcat
vim conf/server.xml
1.找到Engine標(biāo)簽defaultHost屬性把值:localhost改成你自己的公網(wǎng)ip。(有兩處)
2.再找到Host標(biāo)簽的name屬性也是一樣。改成自己的公網(wǎng)ip
3.然后wq!保存
不出意外的話,你現(xiàn)在就可以愉快的訪問(wèn)到了! - 如果你還是訪問(wèn)不了,那你可以看看防火墻了。
1.首先我們看看防火墻是否開啟。輸入firewall-cmd --state返回running說(shuō)明開啟了(如果沒開啟輸入systemctl start firewalld去開啟)
QQ截圖20200203230548.png
2.查看防火墻是否開啟80端口(這里的80改成你tomcat設(shè)置的端口)
輸入firewall-cmd --permanent --zone=public --list-ports(如果返回里面看不到你tomcat的端口,說(shuō)明沒有開啟。那么需要輸入firewall-cmd --zone=public --add-port=80/tcp --permanent 去開啟,里面的80端口改成你tomcat的端口)

3.重啟防火墻并查看8080端口是否開成功輸入:
firewall-cmd --reload,重啟后通過(guò)方法2查看全部開啟的端口,也可以輸入firewall-cmd --zone=public --query-port=80/tcp 單獨(dú)的這個(gè)端口
這次不出意外,你真的可以訪問(wèn)了。
MySQL安裝部署
上面已經(jīng)用過(guò)官網(wǎng)下載軟件上傳解壓安裝的方式了,這次咱們換一種安裝方式;使用的是yum來(lái)安裝??。
- 檢查下是否安裝過(guò)
rpm -qa | grep mysql(還是像往常一樣,沒有任何提示就是沒有安裝;centos7中默認(rèn)安裝了數(shù)據(jù)庫(kù)MariaDB,如果直接安裝MySQL的話,會(huì)直接覆蓋掉這個(gè)數(shù)據(jù)庫(kù),所以咱們就不管這個(gè)了。)
QQ截圖20191128102850.png
PS:如果安裝了, 普通刪除模式 rpm -e mysql - 安裝MySQL官方的Yum Repository
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
QQ截圖20191128142458.png - 下載rpm包
yum -y install mysql57-community-release-el7-10.noarch.rpm
QQ截圖20191128142952.png - 安裝MySQL服務(wù)
yum -y install mysql-community-server
QQ截圖20191128143140.png - 啟動(dòng)MySQL服務(wù)
systemctl start mysqld.service(以Starting MySqL server.. started MysqlServer..結(jié)尾的就成功啟動(dòng)了【注意:是mysqld】) - 如果啟動(dòng)后沒有任何信息,咱們就在查詢下看看是否啟動(dòng)成功。
systemctl status mysqld.service(當(dāng)然一般不提示就是成功了,Linux系統(tǒng)就是這樣。你懂的??)
QQ截圖20191128144731.png - 設(shè)置 mysql 開機(jī)自啟
systemctl enable mysqld(每次重啟服務(wù)器MySQL都會(huì)關(guān)閉的,所以設(shè)置這個(gè)還是可以省去很多事的) - 刷新配置
systemctl daemon-reload(讓它生效) - 設(shè)置mysql密碼
①第一次啟動(dòng)MySQL后,就會(huì)有臨時(shí)密碼,這個(gè)默認(rèn)的初始密碼在/var/log/mysqld.log文件中,所以我們先把初始密碼找出來(lái):grep 'temporary password' /var/log/mysqld.log
QQ截圖20191128150442.png
②登錄:mysql -uroot -pysAE6D%C-HM4(u后面是用戶名(一般為root),p后面緊接著密碼)

③修改密碼:alter user root@localhost identified by '你要修改成的密碼';(不出意外,會(huì)提示你一個(gè)錯(cuò)誤)

他會(huì)告訴你:您的密碼不符合當(dāng)前的策略要求。
啥要求呢?
PS:mysql5.7以上默認(rèn)安裝了密碼安全檢查插件(validate_password),默認(rèn)密碼檢查策略要求密碼必須包含:大小寫字母、數(shù)字和特殊符號(hào),并且長(zhǎng)度不能少于8位。否則會(huì)提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements錯(cuò)誤。
想看密碼策略的可以輸入:
show variables like '%password%';自行去查看
想修改策略的自行百度(有三種策略)。
你也可以省事的直接去除他這種策略
validate_password = off然后使其生效systemctl restart mysqld下圖是修改成功后的圖:

- 刪除(因?yàn)榘惭b了Yum Repository,采用Yum管理各種rpm包的依賴,以后每次操作yum都會(huì)自動(dòng)更新,所以需要卸載它)
①查看安裝的mysql版本rpm -aq | grep -i mysql(記得先退出MySQL 退出命令:\q)
QQ截圖20191128160131.png
②刪除yum -y remove mysql57-community-release-el7-10.noarch
QQ截圖20191128164313.png - 配置遠(yuǎn)程登錄:(MySQL默認(rèn)root用戶只能本地登錄,如果要遠(yuǎn)程連接,要簡(jiǎn)單設(shè)置下)
①首先登錄數(shù)據(jù)庫(kù)(上面有登錄的命令)
②GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '當(dāng)前用戶的密碼' WITH GRANT OPTION;(.的意思是所有庫(kù)的所有表;To后面跟的是用戶名;@后面跟的是ip地址,%代表所有ip地址,identified by后面的是密碼。)
QQ截圖20191128174052.png
③沖刷權(quán)限flush privileges;
QQ截圖20191128174336.png
補(bǔ)充點(diǎn):(我這里沒用到就沒設(shè)置,了解下就行)
需要注意MySQL的配置文件中的bindaddress 的參數(shù)和skip-networking 配置
bindaddress : 設(shè)定哪些ip地址被配置,使得mysql服務(wù)器只回應(yīng)哪些ip地址的請(qǐng)求),最好注釋掉該參數(shù)或設(shè)置成為127.0.0.1以外的值。
skip-networking : 如果設(shè)置了該參數(shù)項(xiàng),將導(dǎo)致所有TCP/IP端口沒有被監(jiān)聽,也就是說(shuō)除了本機(jī),其他客戶端都無(wú)法用網(wǎng)絡(luò)連接到本mysql服務(wù)器,所以應(yīng)該注釋掉該參數(shù)。 - 添加3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent;(可能這個(gè)時(shí)候你防火墻還沒開啟。命令含義: --zone #作用域 --add-port=80/tcp #添加端口,格式為:端口/通訊協(xié)議 --permanent #永久生效,沒有此參數(shù)重啟后失效 ) - 開啟防火墻
systemctl start firewalld - 再重新添加3306端口(使用上面添加2206端口命令命令)
- 重啟防火墻
firewall-cmd --reload
QQ截圖20191128223332.png - MySQL設(shè)置utf8(進(jìn)入ect目錄下)
vim my.cnf
添加:character_set_server=utf8和init_connect='SET NAMES utf8'
QQ截圖20191128224025.png
PS:采用navicat新建數(shù)據(jù)庫(kù)時(shí),需要將編碼方式設(shè)置為,字符集:utf8 -- UTF-8 Unicode ,排序規(guī)則:utf8_general_ci - 再去檢查下阿里云安全組端口是否允許了3306端口。沒有的話開啟就OK了(和上面tomcat允許安全組一樣)
本地開發(fā)工具下載環(huán)境配置及遠(yuǎn)程部署項(xiàng)目
Maven 下載安裝與配置
- Maven官網(wǎng)下載地址(Maven3.2.版本需要JDK1.6的支持,Maven3.3.以上需要JDK1.7以上的支持)
-
下載最新版本
QQ截圖20191203220024.png -
解壓
QQ截圖20191203225921.png -
配置Maven環(huán)境變量(和配java環(huán)境一樣)
1.新建環(huán)境變量MAVEN_HOME和M2_HOME,分別填上你解壓后的路徑(我這里的路徑:C:\zxy\maven\apache-maven-3.6.3)
2.編輯環(huán)境變量Path,追加%MAVEN_HOME%\bin;
QQ截圖20191203230227.png - 檢查是否安裝及配置成功
cmd進(jìn)入DOS命令輸入:mvn -v
QQ截圖20191203224602.png - 修改maven配置文件(settings.xml文件【在conf目錄下】)
主要修改:
1、本地倉(cāng)庫(kù)位置
<localRepository>C:\Users\59908\.m2\repository</localRepository>(C:\Users\59908.m2\repository:可以自行修改位子,隨便創(chuàng)建一個(gè)文件夾做本地倉(cāng)庫(kù))
2、修改maven默認(rèn)的JDK版本(修改成你本機(jī)的版本)
<profile>
<id>JDK-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
3、添加國(guó)內(nèi)鏡像源
<!-- 阿里云倉(cāng)庫(kù) -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
</mirrors>
4、完整的Settings.xml文件(如果上面不會(huì)加的話就復(fù)制完整的文件去里面修改好了)
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
| This is the configuration file for Maven. It can be specified at two levels:
|
| 1. User Level. This settings.xml file provides configuration for a single user,
| and is normally provided in ${user.home}/.m2/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -s /path/to/user/settings.xml
|
| 2. Global Level. This settings.xml file provides configuration for all Maven
| users on a machine (assuming they're all using the same Maven
| installation). It's normally provided in
| ${maven.conf}/settings.xml.
|
| NOTE: This location can be overridden with the CLI option:
|
| -gs /path/to/global/settings.xml
|
| The sections in this sample file are intended to give you a running start at
| getting the most out of your Maven installation. Where appropriate, the default
| values (values used when the setting is not specified) are provided.
|
|-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>C:\Users\59908\.m2\repository</localRepository>
<!-- interactiveMode
| This will determine whether maven prompts you when it needs input. If set to false,
| maven will use a sensible default value, perhaps based on some other setting, for
| the parameter in question.
|
| Default: true
<interactiveMode>true</interactiveMode>
-->
<!-- offline
| Determines whether maven should attempt to connect to the network when executing a build.
| This will have an effect on artifact downloads, artifact deployment, and others.
|
| Default: false
<offline>false</offline>
-->
<!-- pluginGroups
| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
|-->
<pluginGroups>
<!-- pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
-->
</pluginGroups>
<!-- proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| specification in this list marked as active will be used.
|-->
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>
<!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers>
<!-- server
| Specifies the authentication information to use when connecting to a particular server, identified by
| a unique name within the system (referred to by the 'id' attribute below).
|
| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
| used together.
|
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
-->
<!-- Another sample, using keys to authenticate.
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
-->
</servers>
<!-- mirrors
| This is a list of mirrors to be used in downloading artifacts from remote repositories.
|
| It works like this: a POM may declare a repository to use in resolving certain artifacts.
| However, this repository may have problems with heavy traffic at times, so people have mirrored
| it to several places.
|
| That repository definition will have a unique id, so we can create a mirror reference for that
| repository, to be used as an alternate download site. The mirror site will be the preferred
| server for that repository.
|-->
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<!-- 阿里云倉(cāng)庫(kù) -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
</mirrors>
<!-- profiles
| This is a list of profiles which can be activated in a variety of ways, and which can modify
| the build process. Profiles provided in the settings.xml are intended to provide local machine-
| specific paths and repository locations which allow the build to work in the local environment.
|
| For example, if you have an integration testing plugin - like cactus - that needs to know where
| your Tomcat instance is installed, you can provide a variable here such that the variable is
| dereferenced during the build process to configure the cactus plugin.
|
| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
| section of this document (settings.xml) - will be discussed later. Another way essentially
| relies on the detection of a system property, either matching a particular value for the property,
| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
| Finally, the list of active profiles can be specified directly from the command line.
|
| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
| repositories, plugin repositories, and free-form properties to be used as configuration
| variables for plugins in the POM.
|
|-->
<profiles>
<!-- profile
| Specifies a set of introductions to the build process, to be activated using one or more of the
| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
| or the command line, profiles have to have an ID that is unique.
|
| An encouraged best practice for profile identification is to use a consistent naming convention
| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
| This will make it more intuitive to understand what the set of introduced profiles is attempting
| to accomplish, particularly when you only have a list of profile id's for debug.
|
| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
-->
<!--
| Here is another profile, activated by the system property 'target-env' with a value of 'dev',
| which provides a specific path to the Tomcat instance. To use this, your plugin configuration
| might hypothetically look like:
|
| ...
| <plugin>
| <groupId>org.myco.myplugins</groupId>
| <artifactId>myplugin</artifactId>
|
| <configuration>
| <tomcatLocation>${tomcatPath}</tomcatLocation>
| </configuration>
| </plugin>
| ...
|
| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
| anything, you could just leave off the <value/> inside the activation-property.
|
<profile>
<id>env-dev</id>
<activation>
<property>
<name>target-env</name>
<value>dev</value>
</property>
</activation>
<properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
-->
<profile>
<id>JDK-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
<!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
</settings>
-
IDEA配置maven
目前常用的開發(fā)工具如idea,eclipse都自身集成了一個(gè)版本的Maven。但是通常我們使用自己已經(jīng)配置好的Maven
QQ截圖20191203232406.png
最后記得勾選此處,當(dāng)修改pom文件時(shí),Maven就能幫我們自動(dòng)導(dǎo)包了。
QQ截圖20191203232830.png
IntelliJ IDEA遠(yuǎn)程部署項(xiàng)目至阿里云服務(wù)器
Cloud Toolkit插件
阿里云提供了基于 Intellij IDEA 的插件,以方便開發(fā)人員能夠高效的將本地 IDE 中編寫的應(yīng)用程序,極速部署到服務(wù)器中去。
Cloud Toolkit官方地址
-
我們這邊直接在idea中下載File>>Setting>>Plugins
QQ截圖20200205105915.png
下載完后,重啟Idea編輯器即可。
- 配置Cloud Toolkit插件中的Accout信息(這一步很重要)
這個(gè)Accout信息在阿里云的控制臺(tái)中配置(如果是新用戶,需要手動(dòng)創(chuàng)建一個(gè)AccessKey)將鼠標(biāo)放在右上角頭像上,既可以看到AccessKey管理。
QQ截圖20200205111206.png
官方配置文檔
我這里省事就不用子用戶了。
QQ截圖20200205111924.png
創(chuàng)建完后你就可以獲取到一個(gè)AccessKey ID與Access Key Secret

-
賬號(hào)準(zhǔn)備好了,那我們就去配置吧(Tools>>Alibaba Cloud>>Preferences...)
QQ截圖20200205112448.png
QQ截圖20200205112834.png - 配置服務(wù)器與本地關(guān)聯(lián)(右擊項(xiàng)目>>AlibabaCloud>>Deploy to ESC)
QQ截圖20200205125141.png
QQ截圖20200205130125.png
QQ截圖20200205130504.png
Command官方文檔
1.創(chuàng)建restart-tomcat.sh文件,想創(chuàng)建在哪個(gè)目錄就在哪個(gè)下執(zhí)行vi restart-tomcat.sh(后面在Command地方記得改到這個(gè)文件目錄下就行)
2.然后按i 進(jìn)入輸入模式。復(fù)制下面的指令(LuckyJW這個(gè)換成你項(xiàng)目名稱就行。/tomcat/tomcat9這個(gè)就是你tomcat的路徑)
source /etc/profile
# (務(wù)必根據(jù)實(shí)際情況自行添加指令執(zhí)行,如:jps -ml. |grep 你要?dú)⑺赖陌? |xargs. kill)
killall java
rm -rf /tomcat/tomcat9/webapps/LuckyJW
sh /tomcat/tomcat9/bin/startup.sh
3.按esc鍵 輸入 :wq! 回車
4.給restart-tomcat.sh文件賦予權(quán)限 執(zhí)行命令:chmod +x restart-tomcat.sh 回車
5.在/etc/profile這個(gè)文件上添加
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# 這里換成自己jdk的目錄(我之前已經(jīng)設(shè)置過(guò)了,這個(gè)一般都已經(jīng)設(shè)置過(guò)的了。)
#java 1.8
export JAVA_HOME=/java/jdk1.8.0_231
export JRE_HOME=/java/jdk1.8.0_231/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin/$JAVA_HOME:$PATH

6.最后Apply>>Run

7.最后運(yùn)行程序等待部署

運(yùn)行成功后會(huì)出現(xiàn)下圖

你也可以用瀏覽器測(cè)試下

補(bǔ)充下:linux下使用shutdown.sh 關(guān)閉時(shí)可能會(huì)出現(xiàn)SEVERE: Could not contact [localhost:8005] (base port [8005] and offset [0])錯(cuò)誤。(這個(gè)問(wèn)題是因?yàn)樵趖omcat沒完全啟動(dòng)前就關(guān)閉tomcat)

解決:進(jìn)入你jdk目錄(/java/jdk1.8.0_231/jre/lib/security)找到j(luò)ava.security文件。
使用命令
vim java.security進(jìn)行編輯按
/securerandom 進(jìn)行搜索并高亮最后將
securerandom.source=file:/dev/random
改為:
securerandom.source=file:/dev/urandom

這樣就可解決這個(gè)問(wèn)題。這樣修改是提升為啟動(dòng)tomcat的運(yùn)行速度。
現(xiàn)在你的項(xiàng)目是不是已經(jīng)快樂(lè)的運(yùn)行起來(lái)了?
- 下面是扯犢子的屁話??梢院雎裕ㄎ乙彩堑谝淮巫詫W(xué)后臺(tái),所以才會(huì)有這么多問(wèn)題,這么多感慨??)
不不不,你可能還會(huì)像我一樣遇到一些頭疼的問(wèn)題(對(duì)于新手,第一次玩后臺(tái)一定會(huì)遇到各種奇怪的問(wèn)題)。
比如:本地運(yùn)行完美,可已部署到服務(wù)器,mysql就連接不上了。
再比如:本地運(yùn)行完美,可已部署到服務(wù)器,就給你報(bào)靜態(tài)類加載失敗。
等等,等等...
這些問(wèn)題你能發(fā)現(xiàn)那還算好的。畢竟發(fā)現(xiàn)問(wèn)題就可以解決問(wèn)題。
但是對(duì)于很多新手來(lái)說(shuō),本地問(wèn)題可以看idea上的log日志??墒窃品?wù)器上的日志在哪呢?怎么看呢?(網(wǎng)上很多東西,對(duì)于用過(guò)的人來(lái)說(shuō),人家一看就懂,但是對(duì)于萌新來(lái)說(shuō),真的不一定懂。)
我當(dāng)時(shí)按他們步驟操作,就是不行。最后冷靜下來(lái)分析,問(wèn)題出在哪里。對(duì),遇到問(wèn)題一定要自己理解,自己分析。很多東西別人覺得很簡(jiǎn)單,隨便幾個(gè)命令就可以了。但是這命令里面什么意思你懂嗎?這命令里面那些地方需要換成自己本地的路徑你懂嗎?你都不知道。所以你就會(huì)出現(xiàn),照著大神的命令敲,還是解決不了問(wèn)題。
好了,自我吐槽就到這里了。 - 吐槽結(jié)束.............
如何查看云服務(wù)上的日志
方法1:(推薦用方法2??)
使用Xftp工具,或者命令進(jìn)入到你tomcat目錄下的logs目錄。里面就有記錄你服務(wù)器的錯(cuò)誤日志,然后根據(jù)你當(dāng)時(shí)訪問(wèn)服務(wù)器的時(shí)間,找到對(duì)應(yīng)時(shí)間的日志,然后導(dǎo)出來(lái)查看,分析。

看上去很簡(jiǎn)單吧。但是你第一次接觸后端。你可能和我一樣還真不知道在哪里看。
方法1有些麻煩,對(duì)于開發(fā)來(lái)說(shuō),懶那都是通病。因?yàn)閼?,才能?chuàng)新出更多幫助你偷懶的工具??。
方法2:實(shí)時(shí)查看服務(wù)器日志。
這也得感謝偉大的阿里大神們。讓我們節(jié)省更多的時(shí)間去打游戲,不不不,說(shuō)錯(cuò)了,是去學(xué)習(xí)??
方法2也很簡(jiǎn)單。因?yàn)槲覀冎耙呀?jīng)配置了Alibaba Cloud遠(yuǎn)程部署項(xiàng)目了。所以我們只需要在添加一部就可以了。(如果還不會(huì)用Alibaba Cloud遠(yuǎn)程部署的可以看看上面我寫的《IntelliJ IDEA遠(yuǎn)程部署項(xiàng)目至阿里云服務(wù)器》)
①和上面一樣:右擊項(xiàng)目>>AlibabaCloud>>Deploy to ESC
②選擇Advanced
③在Command中輸入命令(命令中的/tomcat/tomcat9,換成你自己服務(wù)器tomcat的路徑)
tail -f /tomcat/tomcat9/logs/catalina.out -n200
④勾選Automatic open after deploy
⑤運(yùn)行 run
這樣就大功告成了

這樣就可以看到實(shí)時(shí)錯(cuò)誤日志啦。

下一篇:APK反編譯工具使用教程







































