preface

Technology that solves user needs is good technology. As a programmer, especially a mobile programmer, do you have any idea to develop a product independently? I’ve always had this idea myself because:

  • A product dream, completely according to their own ideas, independent design and development of an application, should be a sense of achievement.
  • Interoperability of technologiesIf you are an Android developer, you must be familiar with Java. If you use Java’s Spring technology stack to write servers, it is not difficult, especially if many technologies are common
    • Use of design patterns for various frameworks
    • Android Jetpack Room with SpringBoot JPA
    • Dagger and IoC in Spring
    • AOP implementation, modification of bytecode, ASM, AspectJ
    • HTTP request interception and filtering
    • Communication mode across processes
    • , etc.
  • As for our curiosity about technology, I think we should not only limit ourselves to our own area, but also keep our professional position and broaden our horizons. Some time ago, I discussed with my colleagues about the depth and breadth of technology. Based on the second point, sometimes breadth can expand depth.
  • More time during the pandemic, working from home saves time on commuting and leaves more time to do things that interest you.

Therefore, as an Android developer, I designed and developed an App by myself. This article will talk about my understanding and practice of Java server development. This is a simple check-in App. The main page is as follows. By the way, the following App was developed using Flutter.

Flutter page development is not the focus of this article. Here are some of the server-side technologies I used during development.

Architecture diagram

We can have a brief look at the Java server development process as I understand it. First, after the business code is developed by us, it is pushed to the code warehouse GitLab (Github), and then Jenkins, a continuous integration tool, pulls the code for compilation and packaging. Put the Jar or War package into a directory on the server, and finally deploy the Jar or War to run in Tomcat. Finally, Nginx does the reverse proxy to forward requests to different servers. If there are multiple servers, it can also do a load balancing to reduce the pressure on a single server. Then the front-end browser or mobile App can access the request normally.

On each server, we may have different services running on different Tomcat, so there will be communication problems between different services. HTTP or message subscription can be used for communication. Also, not every request accesses the database. For example, when I developed captcha validation, I stored the captcha in Redis. Of course, in the process of online service running, we also need to monitor the running condition. Tools like Zabbix.

The development tools

  • Development tools: IntelliJ IDEA, Android Studio

  • MySQL client: MySQL Workbench

  • Redis client: Another Redis DeskTop Manager

  • Terminal tool: iTerm2

  • Git tool: SourceTree

  • HTTP request tool: Postman

Business framework

. ├ ─ ─ the README. Md ├ ─ ─ pom. The XML ├ ─ ─ roc - CSS - business ├ ─ ─ roc - CSS - data ├ ─ ─ roc - CSS - webapp - app ├ ─ ─ roc - CSS - webapp - browser └ ─ ─ roc-css.imlCopy the code

The project structure is as follows:

  • In the ROC-CSS-data module are model classes, which correspond to tables in the database
  • The ROC-CSS-Business module is the business logic class, and most of the logic is in this module
  • Roc-css-webapp-app module is the HTTP request entry of the mobile terminal, namely Controller, which mainly performs some logic such as parameter verification

Since I am most familiar with Java, I chose the most popular Spring Boot framework for Java Web development when developing business code. Techniques used include:

  • Spring-boot-starter-web: Use this module to turn our project into a Web project
  • Spring-boot-starter-security: user authentication and authentication module, I think this is the difficult part, including the understanding of some filters, interceptors, and how to deal with business logic errors and user authorization errors
  • JWT: JSON Web Token, which is used to generate and verify user tokens and security
  • Spring-boot-starter-data-jpa: for database operations, this part is very simple to use, even we do not need to write SQL statements, but it is not easy to use, especially if you are not familiar with the problem is difficult to check
  • Spring-boot-starter-data-redis: used to operate REDis
  • Lombok: Avoid writing getters and setters
  • Springfox-swagger2, springfox-Swagger-UI: used to generate online interface documents
  • , etc.

You can also use Gradle, which is common on Android.

Service deployment

  • Server: Tencent Cloud Ubuntu

conclusion

These are some of the techniques I used in developing this small project. There may be some shortcomings in my understanding. If you have a better framework or tool choice, please leave a comment. Of course, there are still many problems encountered in the actual development. The code will be gradually improved and developed in the future. Welcome to continue to follow the official account at 9:00 and share Android, Flutter, Java Web and other technologies.

The related resources

Spring – the boot’s official website

Spring security is introduced

JWT’s official website

MySQL Workbench’s official website

Redis client tools

ITerm2 website

More recommended

Nginx getting started

MacOS uses iTerm2 to configure SSH connections

To learn more, please pay attention to the official number: nine o ‘clock off work