Spring Cloud Practical Project – Automatic Front‑Back End Code Generation Tutorial
This tutorial walks through setting up a Spring Cloud micro‑service project by cloning a code‑generator framework, adding backend code, configuring database and Maven settings, launching the generator service, generating CRUD code, and integrating a common utility module with required dependencies.
This guide demonstrates how to build a Spring Cloud micro‑service project with automatic front‑back end code generation.
1. Download the code generator git clone https://gitee.com/renrenio/renren-generator.git 2. Add Renren Fast backend code
Copy the renren-fast folder into the PassJava project root and update the pom.xml with the module entry: <module>renren-generator</module> 3. Modify configuration files
Update src/main/resources/application-dev.yml with your MySQL connection, e.g.:
url: jdbc:mysql://129.211.188.xxx:3306/passjava_qms?useUnicode=true&characterEncoding=UTF-8&useSSL=false<br/>username: root<br/>password: rootEdit src/main/resources/generator.properties to set package, module name, author, etc.
# 以question微服务为例<br/>mainPath=com.jackson0714<br/>package=com.jackson0714.passjava<br/>moduleName=question<br/>author=jackson0714<br/>[email protected]<br/>tablePrefix=qms_4. Adjust controller template
Remove the import of org.apache.shiro.authz.annotation.RequiresPermissions and comment out the @RequiresPermissions annotation in src/main/resources/template/Controller.java.vm.
5. Start the generator service
Run the application and open http://localhost to view the tables of the qms database.
6. Generate code
Click the generate button; the service produces controller, DAO, entity, service implementation, and mapper files.
7. Add a common module
Create a Maven module passjava-common and add it as a dependency to the question module:
<dependency>
<groupId>com.jackson0714.passjava</groupId>
<artifactId>passjava-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>8. Add required dependencies to the common module
MyBatis‑Plus
Lombok
httpcore
commons‑lang
servlet‑api (provided scope)
Each dependency is declared in the common module's pom.xml as shown in the original guide.
9. Add utility classes
Copy utility classes such as Constans.java, PageUtils.java, Query.java, R.java, and RRException.java from the Renren Fast project into com.jackson0714.common.utils, and add XSS/SQL filter classes under com.jackson0714.common.xss.
The result is a fully functional Spring Cloud micro‑service with generated CRUD code and a shared common library for utilities and dependencies.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Wukong Talks Architecture
Explaining distributed systems and architecture through stories. Author of the "JVM Performance Tuning in Practice" column, open-source author of "Spring Cloud in Practice PassJava", and independently developed a PMP practice quiz mini-program.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
