Idea部署SpringBoot多模块服务(jetty)

        找到需要部署的模块,比如A是主模块,B是刚写好的模块,点击idea右边的maven,找到B模块,双击package即打包完成。

        SpringBoot项目需要一个启动的main,可在main入口的pom文件中加入maven插件

 <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

        将jar包上传到linux指定的文件夹下,如果使用命令java -jar xxxx.jar部署的话,不能在后台运行,使用命令nohup java -jar xxxx.jar &,&符号一定不要忘记。

        启动后测试通过,可修改tengine配置,找到tengine所在位置,命令 find -name tengine,进入tengine目录,找到conf目录,进入,使用vi编辑nginx.conf。

        找到nginx.conf里面的server节点,在里面添加配置即可,比如刚部署的项目访问地址是xxx.xx.xx.xxx:8080/test/.......

server{
    listen        80;
    server_name   xx.xxx.xx.xxx(本机地址)
    
    location /test/ {
        proxy_pass http://localhost(具体看部署的服务的ip地址):8080
    }
}

        重启tengine的时候,如果报错,如下:

Redirecting to /bin/systemctl restart nginx.service

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

        很多时候是因为listen的端口被占用,比如这里我配置的80,则我关掉占用的80端口,命令:

sudo fuser -k 80/tcp

        接着再去tengine的sbin目录启动tengine,命令:

service nginx start(启动)(stop停止,reload重启)

        最后访问配置的80,能访问即成功。

猜你喜欢

转载自blog.csdn.net/qq_41061437/article/details/111041896