Lead to
- JDK or JRE must be installed on the server.
- The server needs to install Nacos, Sentinel, Redis, MySQL and other environments. (Depending on project technology selection)
Add the configuration
-
Add the configuration to the pom.xml of the parent (Foot) project
<packaging>pom</packaging> Copy the code
-
Add configuration to pom.xml for each subservice that has an entry class
<packaging>jar</packaging> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> Copy the code
Note: This configuration does not need to be added to the pom.xml of the Common service.
Maven packaging
This article uses Maven automatic packaging, disordered relationships between services dependencies.
In the Maven plugin installed in IDEA, the following information will be displayed under the Maven module of each subservice:
- Lifecycle: A list of commands that will be used frequently.
- Plugins: List of Plugins.
- Dependencies: List of packages on which the service is deployed.
- Open the Maven module for the root project — > Lifecycle
- Click the clean command to clear the target directory for the current project.
- Click the package command to automatically package, and finally the JAR package for each service is in the target directory for each service in the current project.
Note: You can also use the install command instead of the package command, and the install command can also automatically package projects. The difference between the install command and the package command is that the install command takes one step more than the package command. After the package is complete, the install command will deploy the JAR/war to the Maven local repository.
Deploy the jar package
Jar packages for deploying individual services:
java -jar xxx.jar
Copy the code
If the service configuration file (for example, application.yml) contains Chinese characters, the deployment will fail. There are two solutions:
-
Delete all Chinese characters from the configuration file.
-
Add encoding parameters to the deployment command.
java -Dfile.encoding=utf-8 -jar xxx.jar Copy the code
Note: The JAR package for the Common service does not need to be deployed separately.