Actual combat of springcloud microservice architecture: preparation for developing game environment

Time:2021-9-26

Development environment preparation

For the preparation of java development environment, in addition to JDK IDE, other tools or services need to be prepared to facilitate some common operations such as code management, development and debugging, as follows:

Java SDK
IntelliJ IDEA
Git
Consul
MySQL and its client
Mongodb and its client
Redis
RabbitMQ

Select the version of the JDK

JDK needs to use version 1.8 or above. Readers can select relevant installation packages from the Internet according to their own operating system.

The examples in this paper are developed based on JDK 1.8, and the developed applications are also published using java images.

In principle, the higher version JDK has downward compatibility, but if the higher version JDK is used in the development process, the same or higher version must be used for application release.

Download lntellij idea

Eclipse, netbean, IntelliJ idea and others are excellent Java integrated development tools. This article recommends readers to use IntelliJ idea (idea for short), and the examples of this article are also developed using this toolgameof Idea is not only excellent in intelligent code assistant, project management, version control and other aspects, but also contains some commonly used tool plug-ins, which do not need us to search and install. For example, Maven idea provides comprehensive and unique support for the development of spring cloud. Readers can download and install idea from Gongwang.

Idea fully supports the creation and development of projects such as spring spigboot, spring cloud, Java EE, Android JavaScript, HTML / CSS and node.js.

Of course, it is also possible to use other ide development tools. Some operations may be different in different development tools. Readers can use them according to the relevant instructions.

Download and configure git client

The idea includes CVS (Concurrent Versions System), subversion GIT and other version control management tool plug-ins. In order to use the code warehouse, we also need to install a git client. Readers can select the appropriate client version from the official website according to their operating system and download and install it.

After installation, configure the execution path of GIT www.cungun.com in the idea.

Figure 4-1 shows a configuration example using MacOS, where the path is configured as “/ usr / local / bin / git”, that is, the GIT installation path. If the configuration is correct, click the “test” button to return the prompt of successful execution and the version number of GIT.

Create a spring cloud project

Now, we use the idea spring cloud project. The following instance projects can be extended by this project.

Select Create a new project in the file list and select the spring initializr option. In this way, you can use the default link address to create a spring project through the spring official website, as shown in Figure 4-2.

Finally, a very simple web application project with the latest release of spring cloud is generated. Open this project, and we can see the following version information in the project object model pom.xml:

org spri gframework.boot /groupid>spri g-boot start_§ r-parent /artifac id>2 . l . 6.RELEASE< !– lookup parent from repository –>com.exampledemo0 . 0 . 1- SNAPSHOTdemoDemo project for Spring Bootl . 8Greenwich . SR2…

As can be seen from the above code, the version of spring cloud is greenwich.sr2, and the version of spring boot development framework it uses is 2.1.6.release

From the generation of the project to now, although we have not written a – line of code, this is a complete project project, which can be compiled and run. However, running this project now will not provide any available functions. Therefore, we add a few lines of code to enable it to output a “Hello world!” message when receiving the request:

@RequestMapping(value =”/”)
public String index() {
return “Hello World!”;
}

After starting the project, if we enter the following link in the browser, we can output the information of “Hello world!”:

Recommended Today

Seven Python code review tools recommended

althoughPythonLanguage is one of the most flexible development languages at present, but developers often abuse its flexibility and even violate relevant standards. So PythoncodeThe following common quality problems often occur: Some unused modules have been imported Function is missing arguments in various calls The appropriate format indentation is missing Missing appropriate spaces before and after […]