More than a bag flat, industry is not fine

0. Basic introduction

As a programmer at the Android software level, interacting with the back end is quite common, and sometimes there are all kinds of disagreements and incomprehensible situations.

And I wrote this series is committed to make Android and back-end interaction communication easier, so that Android applications are not confined to just front-end development.

To do a good job, he must sharpen his tools. When we build the backend framework, we should first prepare our IDE, so that we can achieve twice the result with half the effort

Here, I’m using Intellij IDEA, which is not too easy to use for Android Developer used to Android Studio.

Download the intellij IDEA

Note: HERE I use Intellij IDEA Ultimate student licensed free

1. Create an empty Maven project

When Intellij IDEA is opened, the initial interface of Intellij IDEA is shown in Figure 1-1

FIG. 1-1

FIG. 1-1:

Create a new Maven project,

Figure 1-2:

Check the blue box and select Maven’s WebApp in the red box to create it.

Figure 1-3:

GroupId: organization ID, equivalent to the Company domain when creating a project with Android Studio

ArtifactId: project name

Your package name is GroupId+ArtifactId, for example, com.seeyou.sumn.ssmdemo, as shown in Figure 1-3

GroupId and ArtifactId are collectively referred to as “coordinates” to ensure project uniqueness if you want to move your project to maven’s local repository

To find your project, you must use these two ids.

Next step

Figure 1-4

Figure 1-4:

Check the Override in the red box, here we need to download Maven, because intellij IDEA’s built-in Maven download speed is too slow. Of course, if you are confident that the Internet is fast, you can skip this step, and we can download it from Maven’s official website

Figure 1-5

As shown in Figure 1-5, unzip it to the desired directory

Figure 1-6:

Open it with notepad or notepad++ (recommended). Next we will set up the alibaba warehouse address for maven as shown in figure 1-7.

Figure 1-7:

 <mirror>
      <id>nexus-aliyun</id>
      <mirrorOf>*</mirrorOf>
      <name>Nexus aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror> 
Copy the code

Figure 1-8:

Then, as shown in Figure 1-4 and Figure 1-8, you have already set up your own maven download. If you do not want to download the JAR to disk C to save space on disk C, you can also check the Override of local Repository and select the folder you want. Then next and finish. An empty Maven project has been created and we can move on.

2. Set the Maven project

Figure 2-1 shows the structure of a project

After creating the folder, set the folder, as shown in Figure 2-2

Set the Java folder to Sources Root

Resource Set to resource Root

We then need to create a test folder in the main directory for unit testing. See Figure 2-3

Figure 2-3

Set the Java in test to Test Sources Root

Resource set to Test resource Root

You can also right-click the project – select Open Module Settings to Open the project configuration page changes as shown in Figure 2-4

Finally, we create the required package name in the Java file, so that a Maven project is completed, as shown in Figure 2-5

3. Configure tomcat

Tomcat Download address

Tomcat 8 is used in this project

Figure 3-1

The project uses a decompressed version

Figure 3-2

Open the Edit Configuration window if shown in 3-2

Figure 3-3: Click Add and select Tomcat Server Local

Figure 3-4: Click Configuration to configure Tomcat Home as the address of the file you just installed/unzipped

Finally, configure the war package to run

Finally, we are ready to run our Maven-based Web project in Tomcat

Hello World!