Service deployment

Record the reason

Will local SpringBoot The project by war The package is deployed to the virtual machine , Verify the server deployment .

Use war The package is to facilitate the replacement of configuration files and so on .


object edition
Spring Boot 2.4.0
VMware Workstation Pro 16
Git 2.9.4
maven 3.3.9
JDK jdk1.8.0_281
Tomcat 9.0.45
Redis 6.2.1

Tomcat Version needs to be associated with SpringBoot The built-in version is consistent with the large version , Otherwise there will be problems

The virtual machine installation is not detailed here .


  • Enter the cd /usr/local/src Catalog , Enter the download link :

  • decompression

    tar -zxvf git-2.9.4.tar.gz
  • Installation and compilation Git Package needed for ( One sentence at a time )

    yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
    yum install gcc perl-ExtUtils-MakeMaker
  • Delete existing Git

    yum remove git
  • Compilation and installation

     Go to the root directory :cd /usr/local/src/git-2.9.4
    The installation to /usr/local/git Catalog :./configure --prefix=/usr/local/git
    Compilation and installation :make && make install
  • Create soft chain :

    ln -s /usr/local/git/bin/* /usr/local/bin/
  • Verify that the installation is complete

    git --version


  • Check maven Whether to install

    mvn -v
  • stay /usr/local/src Download under directory maven Compressed package

  • Decompress the package

    tar -zxvf apache-maven-3.3.9-bin.tar.gz
  • Move to /usr/local

    mv apache-maven-3.3.9 /usr/local/maven3
  • Configure environment variables

    • Open environment variable file profile

      vim /etc/profile
    • Add environment variables at the end

      export MAVEN_HOME=/usr/local/maven3
      export PATH=$MAVEN_HOME/bin:$PATH
    • tips: Here's the preparation part Linix Text editing commands

      i Enter edit mode - Start typing... At the cursor position 
      esc Exit edit mode
      :wq After exiting edit mode, save the file and push it out more
    • Make configuration effective

      source /etc/profile
  • Check if the installation is successful

    mvn -v


  • Check for installation

    java -version
  • install JDK It is recommended to use after downloading the installation package locally winSCP And so on software uploads from the local to the server , Be sure to download the correct version (jdk-8uxxx-linux-x64.tar.gz).JDK The download address is as follows :
  • Will download okay JDK The installation package is uploaded to the server /usr/local/src Under the table of contents , Unzip after upload .

    tar -zxvf jdk-8u201-linux-x64.tar.gz
  • Will unzip OK JDK Move to /usr/local Next

    mv jdk1.8.0_201 /usr/local
  • Configure environment variables

    • Go to configuration file

      vim /etc/profile
    • After adding the following environment variable configuration, save and exit :

      export JAVA_HOME=/usr/local/jdk1.8.0_201
      export JRE_HOME=/usr/local/jdk1.8.0_201/jre
      export PATH=$JAVA_HOME/bin:$PATH
      export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
    • Make configuration effective

      source /etc/profile
  • Verify the installation

    java -version


  • download Tomcat To the same level , adopt filezilla Wait for tools to upload to /usr/local in
  • decompression

    tar -zxvf apache-tomcat-9.0.45.tar.gz
  • If you have obsessive-compulsive disorder , The compressed package can be deleted

    rm /usr/local/apache-tomcat-9.0.45.tar.gz
  • start-up

    sh /usr/local/apache-tomcat-9.0.45/bin/
  • close

    sh /usr/local/apache-tomcat-9.0.45/bin/
  • Real time log view

    tail -500f /usr/local/apache-tomcat-9.0.45/logs/catalina.out


  • Download it locally redis Upload to the server or download directly from the server . I choose the stable version to download , To the virtual machine .
  • decompression

    tar -zxvf redis-6.2.1.tar.gz
  • Yum install gcc rely on , And compile and install redis

    cd /usr/local/redis-6.2.1
    yum install gcc
    make MALLOC=libc
    cd src && make install
  • start-up redis( In addition, it can be configured as a service )


Connect different problems to solve

  1. ping ip

    ip Different check firewalls

  2. The virtual machine checks whether the port number is on

    After modifying the port, you need to restart the firewall service to take effect

    centos8 Check that the port is on 
    firewall-cmd --query-port=8080/tcp
    Open port
    firewall-cmd --zone=public --add-port=8080/tcp --permanent
    service iptables restart :
    systemctl restart firewalld.service

    here centos8 The port number is different from the previous version .

    In the beginning, virtual machines Tomcat When I got up, I windows visit 8080 Port failure , According to these two steps, the visit is successful .

Project preparation

If using Idea Build a new project , You can choose how to package when you create it , If you build with jar package , We need some changes .

The new project

When building, choose the packaging method as war package

Jar Package items

It means that the packing method is jar Project .

  • You need to ignore the built-in Tomcat, The local runtime needs to use . So the local runtime turns off annotations .

    <!-- Ignore the built-in tomcat Containers -->
  • Ignore the built-in Tomcat At the same time , Need to add extra servlet rely on

    <!-- Because of ignoring the built-in tomcat Containers , Therefore use javax.servlet Method requires additional dependencies -->
  • add to war Package name , Ignore packaging files ( Optional )

    <!-- Ignore the custom class configuration prompt tool when packaging -->


There are two ways .

  • Idea Click on Bulid>Build Artifacts> choice demo.war

  • Use maven The packing order of

    mvn clean package


  • Will be packed war Package pass filezilla Etc. to the virtual machine tomcat Under the webapp Directory

  • Start... On the virtual machine Tomcat, And access , The response to the request is successful

Step on the pit

Tomcat After starting , Use the following log command to monitor project startup , When problems arise, it's intuitive .

tail -500f /usr/local/apache-tomcat-9.0.45/logs/catalina.out
  • Regardless of the port number of the local configuration of the project 、 visit url What is it? , Deploying to a virtual machine uses Tomcat The port number of plus war Package name , Such as 8080/demo/

  • Because I'm accessing a local database , So you need to modify the database address in the project configuration file , Deployment project error

    java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect...

    This is because the database server does not give access to the service deployment server , Please refer to

SpringBoot project war More articles on package deployment

  1. springboot project war Package deployment and problems Failed to bind properties under 'mybatis.configuration.mapped-statements[0].

    1. modify pom file Modify the packing method by war: add to tomcat Using range ,provided It means that there is an external supply at the time of release , Built in tomcat You don't pack it in <groupId>com.scho ...

  2. springBoot project war Package deployment and change to war The problem of resource path error after package

    Reference material : ...

  3. IDEA Multi module parent-child dependency maven project war Package deployment

    IDEA Multi module parent-child dependency maven project war Package deployment Posted on 2018-04-25 | In IDEA | | Visitors 286 IDEA Its full name is IntrlliJ IDEA, It's a very ...

  4. take Web project War Package is deployed to the Tomcat The server

    1. To configure Java Running environment 1.1  Download and install JDK Download the latest JDK: , Download and install , Choose to put JD ...

  5. tomcat function springboot project war package

    With the simplest spring boot demo Project to demonstrate how to publish a project war Package to tomcat, And it runs successfully ( There will be a lot of little friends 404 error ) One . Prepare one of the simplest demo project stay IDEA New project in , always ne ...

  6. java web project war Package deployment , Use tomcat Set authentication for the specified interface

    Let's briefly talk about the needs : To base one on springboot2.0 Developed java web The project into war package , adopt tomcat Deploy to one linux Server , Some pictures and other resources related to the project are also placed on the server according to certain rules ...

  7. springboot hit war Package deployment tomcat The server , And form submission data garbled processing

    Xiaobai thinks springboot become involved jar The package directly uses the embedded tomcat or jetty Containers (java -jar xxx.jar) Running projects is not conducive to positioning problems , I'm still used to checking tomcat or nginx To locate the problem ...

  8. IntelliJ IDEA pack WAR And deploy and run (mac osx) take Web project War Package is deployed to the Tomcat Server basic steps ( Full version )

    use IntelliJ IDEA do web The development experience is great , But export war Baubi eclipse It's a lot of trouble , Here's the solution : pack :1. Automatic packaging :File —> Project Structure —> ...

  9. take Web project War Package is deployed to the Tomcat Server basic steps

    Reference source : 1. common sense :   1.1 War package War The package is generally in progress Web ...

  10. take Web project War Package is deployed to the Tomcat Server basic steps ( Full version )

    1. common sense :   1.1 War package War The package is generally in progress Web When developing , It's usually a website Project The collection of all source code under , It contains the front desk HTML/CSS/JS Code for , Also contains Java Code for . When developers are on their own ...

Random recommendation

  1. mongodb Operation command

    Connect mongodb:(mongo The command opens a javascript shell. therefore js Grammar works in all of this )mongo 192.168.18.xx:27088/ups -uusername -pp ...

  2. java 22 - 14 JDK1.5 After the Lock lock

    In the process of solving thread safety before , Although we can understand the lock object problem of synchronous code blocks and synchronous methods , But we didn't see directly where the lock was put , Where is the lock released , For a clearer expression of how to lock and release locks ,JDK5 A new lock pair was provided later ...

  3. jQuery Add delete elements

    $(document).ready(function () { $('#radioExtranet').on('click', function () { showProjectInformation ...

  4. Fast learning algorithm of deep trust network (Hinton The paper of )

    Nothing original , That is to enrich my blog in the process of deep learning , Hey . No joy, no spray. ! Hinton It's a big bull in deep learning , It's not wrong to follow Daniel -- source :A fast learning algorithm fo ...

  5. Git The label management of the course

    When you release a version , We usually put a label in the version library first , such , It's the only version that defines the time of tagging . Whenever in the future , Take a version of a label , Is to take out the historical version of the time when the label was placed . therefore , The tag is also a snapshot of the version Library .Git Of ...

  6. to disable the entity lazy load, The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

    The ObjectContext instance has been disposed and can no longer be used for operations that require a ...

  7. Python call C/C++ All kinds of ways to do it

    Python call C/C++ All kinds of ways to do it 2010-12-07 09:59 28433 Human reading Comment on (1) Collection Python It's an explanatory language , The bottom floor is for c Realized , So use python call C It's easy , below ...

  8. Spring MVC Study note 1 HelloWorld

    Spring MVC Study note 1 HelloWorld Spring MVC The following steps can be followed for the use of ( Use Eclipse): Join in JAR package stay web.xml Middle configuration DispatcherServlet ...

  9. mysql_ Build table

    Build table Multiple default values for a field Create table time , When you set more than two default values for multiple fields , Use a comma between the two default values ',' separate , No spaces . create table student2( id int not null, n ...

  10. Python_ object-oriented _ class 1

    object-oriented : Reduce duplicate code , Increase of efficiency , More efficient than functional programming Class creation : Instance properties are also called : Member variables , Member attribute ( Or fields ) Three characteristics of object-oriented : One . encapsulation Encapsulate objective things as abstract classes , Only one available interface is exposed Use ...