Angular+SpringBoot前后端分离项目上传云服务器

news/2024/7/6 5:32:50

一、前端(客户端)上传服务器

1、安装nginx,开启服务,查看状态

安装:yum install nginx
开启服务:service nginx start
重启服务:service nginx restart

2、打包Angular项目–控制台输入

打包命令:ng build --prod

3、上传项目文件到nginx的html下

找到dist文件,用xftp工具上传即可

4、浏览器访问公网IP,看到项目运行说明客户端上传成功

二、后端(服务端)上传服务器

1、添加打包JAR所需的maven依赖项(idea)

<build>
        <finalName>SpringbootMybatis</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <archive>
                                <manifest>
                                    <mainClass>
                                        edu.ynmd.cms.Main  <!-- 注意:这里的edu.ynmd.cms是项目的包名,Main是启动类的名字 -->
                                    </mainClass>
                                </manifest>
                            </archive>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

2、控制台输入命令把项目打包为JAR包

mvn clean package
项目下会有一个dist文件,复制jar包

3、把JAR包和数据库文件通过xftp一起上传到云服务器

4、项目文件下输入linux命令运行jar包

后台不挂断运行:
nohup java -jar SpringbootMybatis-jar-with-dependencies.jar --server.port=6060 >temp.txt &
注意:端口号需要和前端数据接口对应

强制关闭端口:
lsof -i :6060|grep -v "PID"|awk '{print "kill -9",$2}'|sh

5、浏览器再次访问网站,发现前后端已经一起运行了。


http://www.niftyadmin.cn/n/3649369.html

相关文章

删除安装包 react包_如何包装在React中使用的Vanilla JavaScript软件包

删除安装包 react包介绍 (Introduction) Complex web projects often require the use of 3rd party widgets. But what if you’re using a framework and the widget is only available in pure JavaScript? 复杂的Web项目通常需要使用第三方控件。 但是&#xff0c;如果您…

CentOS 7下载及安装教程

▣ 博主主站地址&#xff1a;微笑涛声 【www.cztcms.cn】 操作系统基本上都有服务器版本&#xff0c;像Windows有Windows server版本。服务器版即为可以搭建各种开发环境的系统&#xff0c;运行非常稳定。本教程是CentOS 7在虚拟机(VMware Workstation Pro 15)的安装教程。由于…

PHP利用数据库生成API

第一步&#xff1a;首先利用HBuilder建立一个PHP项目&#xff1a; 新建一个php文件,与数据库建立连接: <?php $conmysql_connect("localhost","root","") or die(mysql_error); mysql_select_db("test");//test为表名 ?…

Xftp和Xshelll的安装—远程连接linux

什么是xftp和xshell呢&#xff0c;来看看百度词条的解释。 Xftp——是一个功能强大的SFTP、FTP 文件传输软件。使用了 Xftp 以后&#xff0c;MS Windows 用户能安全地在 UNIX/Linux 和 Windows PC 之间传输文件。 Xshell——是一个强大的安全终端模拟软件&#xff0c;它…

react-hooks_如何使用React Hooks构建React To-Do应用

react-hooks介绍 (Introduction) React is a front-end JavaScript library that can be used to create interactive user interfaces for your application. In this tutorial, you will create a to-do app that covers all four aspects of a CRUD: Create, Read, Update, …

云服务器和域名的购买—华为云

现今国内主流的云服务器厂家有华为云、阿里云、腾讯云等。老牌的有西部数据。而国内市场几乎被这三家占有。三家公司的云服务器各有优势&#xff0c;总体来说都不错。选择华为云是因为它相对安全和稳定。云服务器和域名都在华为云进行购买。在其他公司购买的流程也大致相同。 …

[EnterpriseServices]利用assembly定义我们的组件在COM+中的注册方式

整理者 郑昀UltraPower 利用以下assembly定义我们的组件在COM中的注册方式&#xff0c;其中&#xff1a;ApplicationName 属性是"COM 目录"和"组件服务管理"控制台中显示的 COM 应用程序的名称。[assembly: ApplicationName("MyDLL.Interface")]…

bat命令行遍历文件_命令行基础知识:如何遍历目录中的文件

bat命令行遍历文件Looping is one of the most powerful things you can do in programming. It allows you to apply the same logic over and over to a group of items with minimal code. If done properly, infinite loops can be a blessing instead of a curse. Unfortu…