Azure虚拟机上部署Spring Boot项目

1.下载安装JDK8,Maven, Git在Azure虚拟机上,并且配置好环境变量,具体配置不在介绍

在命令行窗口验证是否安装成功.

2. 使用Git克隆Spring Boot Sample Project

git clone https://github.com/spring-guides/gs-spring-boot

3. 使用Maven构建Spring Boot项目Jar包

mvn clean package

4.使用Maven在虚拟机上运行构建的Spring Boot项目

mvn spring-boot:run

5. 查询项目是否部署成功

http://localhost:8080

6. 本地访问虚拟机上的Spring Boot 失败(8080端口没有开放)

7.在Azure Portal上设置虚拟机的Inbound Rule允许8080端口访问

8. 在虚拟机上设置防火墙允许8080端口访问

9. 在步骤7跟8配置好8080端口的访问权限后,本地就可以访问Azure虚拟机部署的Spring Boot程序了

10. Spring Boot项目连接到Azure的MySQL数据库

 在Spring Boot工程中,将数据库的URL, Username跟Password改成Azure上的MySQL数据库连接

同时将Azure虚拟机的IP地址通过Azure Portal添加到MySQL的防火墙报名单中!

猜你喜欢

转载自www.cnblogs.com/brightleowang/p/11116920.html