The Arya-Spring-Vue full stack project starts with Vue, TypeScript, IView, Spring-Boot, and MySQL as the technology stack, even though it is the front end.

Front-end file deployment has been initially mastered: how to deploy the front-end dist directory? .

But the server is a little confused: one is not the back end, usually do not have this experience; On the other hand, both Node full-stack projects and Vue + Spring full-stack projects have only been successfully run locally.

Arya-Spring-Vue-Be has just been successfully deployed to a CentOS Tencent cloud server. Take note while it is hot.

  • Front knowledge
  • The Spring Boot Maven Plugin packages the JAR package embedded with Tomcat
  • CentOS installs the JDK and sets the environment variables
  • CentOS7 MySQL installation
  • Create a new database and user and run the JAR package

Front knowledge

Maven, Tomcat, Jar. Although I have experience with NodeJS server, I am new to the Java technology stack, so I have the following questions:

  • How does the Java server run on the server?
  • Will you build a dist-like package like the front end?

Before I think about these two questions, let me add some preknowledge.

Maven: [[translation] maven in 5 Minutes] (https://github.com/FrankKai/j… , [[translation] Maven Getting Started Guide] (https://github.com/FrankKai/j… Tomcat: Apache tomcat experience at the beginning of the jar: [[translate] Create a Fat jar App with Spring Boot] (https://github.com/FrankKai/j… , [[translation] Running a Spring Boot App with Maven vs the an Executable War/Jar] (https://github.com/FrankKai/j…

How does the Java server run on the server? JAR packages running in the Tomcat environment Embedded Tomcat JAR package. Will you build a dist-like package like the front end? Yes, usually a JAR package, but it can also be a WAR package. MVN Package or MVN Package spring-boot:repackage.

The Spring Boot Maven Plugin packages the JAR package embedded with Tomcat

Spring-boot project arya-spring-vue-be maven is installed JDK is installed

pom.xml

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

packaging

mvn clean package spring-boot:repackage

Package the embedded Tomcat jar: arya-spring-vue-be-0.0.1-snapshot.jar

CentOS installs the JDK and sets the environment variables

Install the JDK

Mkdir /usr/ Java # create Java folder CD /usr/ Java # enter Java folder

Download jdk-11.0.5_linux-x64_bin.tar.gz locally. Use Filezila to upload the JDK installation package to the Java folder above, and then unzip the installation package.

// Unpack the installer chmod +x jdk-11.0.5_linux-x64_bin.tar.gz tar-xzvf jdk-11.0.5_linux-x64_bin.tar.gz
// Set the environment variable to open /etc/profile. vim /etc/profile

Enter the following configuration and save:

Export JAVA_HOME = / usr/Java/JDK - 11.0.5 export CLASSPATH = $JAVA_HOME/lib/tools. The jar: $JAVA_HOME/lib/dt. The jar: $JAVA_HOME/lib export PATH=$JAVA_HOME/bin:$PATH
// The configuration file takes effect immediately source /etc/profile

CentOS7 MySQL installation

[[translate] How To Install MySQL On CentOS 7] (https://github.com/FrankKai/j…

In sudo yum install mysql-server, there are some pits, and the second is that downloading mysql-server requires some waiting time.

Create a new database and user and run the JAR package

See https://github.com/arya-sprin…

See the following database configuration

spring.datasource.url=jdbc:mysql://localhost:3306/arya_spring_vue_be
spring.datasource.username=arya_spring_vue_user
spring.datasource.password=password

So the database and users are created

mysql> create database arya_spring_vue_be;
mysql> create user 'arya_spring_vue_user'@'%' identified by 'password';
mysql> grant all on arya_spring_vue_be.* to 'arya_spring_vue_user'@'%';

Run the jar package: jar-jar arya-spring-vue-be-0.0.1-snapshot.jar

. ____ _ __ _ _ / \ \ / ___ '_ __ _ _) (_ _ __ __ _ \ \ \ \ (\ ___ () |' _ | '_ | |' _ \ / _ ` | \ \ \ \ \ \ / ___) | | _) | | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.3. RELEASE) the 2019-11-29 18:05:43. 10520-092 the INFO [main] C.A.S.V.A.A ryaSpringVueBeApplication: Starting AryaSpringVueBeApplication v0.0.1 - the SNAPSHOT on VM_0_11_centos with PID 10520 (/usr/ Java/arya-spring-vue-be-0.0.1-snapshot. jar started by root in /usr/ Java)... The 18:06:00 2019-11-29. 10520-154 the INFO [main] O.S.B.W.E mbedded. Tomcat. TomcatWebServer: tomcat started on the port (s) : 8080 (HTTP) with the context path '18:06:00 2019-11-29. 10520-184 the INFO [main] C.A.S.V.A.A ryaSpringVueBeApplication: Started AryaSpringVueBeApplication in 19.419 seconds (JVM running for 21.197)
  • Nice Spring hints
  • Tomcat is running successfully on port 8080
  • AryaSpringVueBeApplication successfully started

At this point, the backend JAR package is deployed successfully!

Original address: https://github.com/arya-sprin…

I look forward to communicating with you and making progress together. Welcome to join my technical discussion group which is closely related to front-end development:

  • SegmentFault Technical Circle: New ES specification syntax sugar
  • SegmentFault Column: Be a good front-end engineer while you’re young
  • Zhihu: Be a good front-end engineer while you are still young
  • GitHub Blogs: 233 personal blogs while you’re still young
  • Front-end development QQ group: 660634678
  • WeChat public account: human beast ghost/excellent_developers

Strive to be a good front-end engineer!