Kill the front! 3 minutes pure Java annotation to build a management system

Time:2021-9-21

Hello, I’m Xiaofu~

Recently, I came into contact with a new project and found that it used an interesting framework, which can be said to realize my dream when I first entered the industry, so I keep sharing it with you.

I haven’t separated the front and back end of the projects I just started working with. I often need the back end to maintain the page. Sometimes I feel that I’m not suitable for the front end. If you let me study the back-end technology, look at the middleware source code, and analyze the underlying principle of the framework, it’s not a big problem. I do it occasionallyJSit’s fine too. If you let me write acssStyle, that’s terrible. I’m not interested at all. I don’t know if it’s the same as me.

Kill the front! 3 minutes pure Java annotation to build a management system

There is no need to write a page for the framework to be introduced today. Let’s go straight to the topic below

EruptA general background management framework is said to haveUltra low code volumeZero front end codeZero curd operationThere is no need to create a tablePure Java annotation developmentIt is claimed that a complete background management system can be built in three minutes.

Er ~ it sounds like a lot of criticism. Is it so magical? Let’s use it together and feel it.

First, let’s build an environment. At presentEruptsupportJavaedition1.8.0And aboveSpring Bootedition2.0And above.

Build easy

pom.xmlIntroduce necessaryjarpackage

<dependencies>

application.ymlAs long as you simply configure the data source, prepare a database in advance. When it comes to the database, I’ll say a little episode.

I was inGithubWhen submitting case code(https://github.com/chengxy-nds/Springboot-Notebook), because I didn’t pay much attention to the sensitive information, the cloud database account was leaked. Recently, I found that a small partner had run a project on the database. I looked carefully at the data structure inside and found that it looked like a completed project.

Kill the front! 3 minutes pure Java annotation to build a management system

The library itself is medemoA test library of cases is designed to enable small partners to spend more time on the technical points of studying cases and reduce the trivial matters of building an environment without technical content.

I found that I didn’t change my password or delete their library here. If you want to use it, you can continue to use it, but play it, make it, make it,You can’t move. It’s not your data! It’s not good to affect others’ study.

spring:
  datasource:
    url: jdbc:mysql://47.93.6.5:3306/erupt2?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
    username: root
    password: 123456
  jpa:
    show-sql: true
    generate-ddl: true
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: mysql
  profiles:
    active: dev
  mail:
    username: [email protected]
    password: xxxxxxx
    host: smtp.qq.com
    properties:
      mail.smtp.ssl.auth: true
      mail.smtp.ssl.enable: true
      mail.smtp.ssl.required: true
server:
  port: 8888

A little digression, let’s continue~

Actually, hereEruptThe environment is finished, eh ~, is it finished?

We haven’t done anything. The project is an empty shell. We haven’t written a line of code. It seems that we haven’t even built a table!

Kill the front! 3 minutes pure Java annotation to build a management system

Don’t worry. Let’s start the project first and see that many table creation and insertion statements are printed on the console becauseEruptFramework underlying applicationJPAFor persistence, the preset creates some system tables and data.

Kill the front! 3 minutes pure Java annotation to build a management system

be carefulEruptThe preset table will only be built once when the project is started for the first time. If you want to recreate it, you need to delete it.EruptFile (usually in the workspace of the project), how to obtain the file location

System.getProperty("user.dir")

Look at the 16 system tables created in the database, includinge_upms_userTable is a user table. By default, there is only one administrator account, and the user name and password areerupt

Kill the front! 3 minutes pure Java annotation to build a management system

Then we visitedhttp://127.0.0.1:8888/, let’s see what the effect is. There is a complete login page.

Kill the front! 3 minutes pure Java annotation to build a management system

Log in directly with the user name and password above,eruptThe complete permission control and other functions have been realized in advance, and we have hardly written any code here. They are all encapsulated by the framework. All menu data are dynamically obtained from the database, and a basic background management system is built. It’s a little wow.

Kill the front! 3 minutes pure Java annotation to build a management system

Interesting pages

So here comes the question…? What if you want to customize the page?

We said it at the beginningeruptZero front-end code, all based onJavaAnnotation development, next useJavaNotes to write a simple page experience.

eruptThere are two core annotations@Erupt@EruptField

  • @EruptAnnotation modifier class, representing the definition of a page
  • @EruptFieldAnnotation modifies the field, representing the field name displayed on the page
  • @PowerAnnotation controls whether to operate buttons, such as add, delete, modify, query, import, export, etc
  • @SearchAnnotation indicates that the field is a search condition
  • @TableAnnotation indicates that the page takes the table corresponding to the data. If it is not set, a table name consistent with the class name will be automatically created according to the class field value when the page is initialized for the first time.

There are a lot of annotation types. I won’t list them one by one. I’ll go to the official website to see more:https://www.erupt.xyz

Next, we define aStudentClass, plus@Erupt@EruptFieldAnnotation, so that even if the pages and elements are finished, is it a bit subversive.

/*

However, the newly created page will not be displayed at this time. We need to manually make a mapping relationship and customize a menu in menu maintenance,Type valueBe sure to create a newClass name Student

Kill the front! 3 minutes pure Java annotation to build a management system

After saving and refreshing, we will see that our new page appears, and the function of the page is very complete. The basic operation, query, import and export functions are automatically realized.

Kill the front! 3 minutes pure Java annotation to build a management system

A new student information is added to the page, corresponding toStudentThe table also has more records, and the persistence process is completely done by the framework.

Kill the front! 3 minutes pure Java annotation to build a management system

althoughEruptThe framework deeply encapsulates the front and back-end code, but it provides rich and flexible user-defined interfaces to meet our personalized needs.

For example, when we enter new student information, we want to block the name asZhang SanYou can act as an agent for the page button functiondataProxyTo implement custom logic, you can implement the corresponding method for which button agent, such asbeforeAddafterAddIs a proxy for the new button.

@Getter

When we enter the name asZhang SanWhen the students successfully shielded. There are many other similar functions, not one by one. Look at the documents~

Kill the front! 3 minutes pure Java annotation to build a management system

If we want to develop the interface in the traditional way, we don’t have to worry about itEruptThe page generation rules of are in conflict and will not be affected at all. andEruptInternal integrationJPA, off the shelfdaoInterface, just call the corresponding API to start development.

Kill the front! 3 minutes pure Java annotation to build a management system

If you don’t want to writeJavaThe code doesn’t matter,EruptIt also provides a code generator to customizeJavaClass name and field name can generate code directlycopyThat’s it.

Kill the front! 3 minutes pure Java annotation to build a management system

Kill the front! 3 minutes pure Java annotation to build a management system

Speaking of this, I only introducedEruptThe basic feature of yidui is mainly to let the little partner know that there is such an agile weapon.

Not only that, it also supports rich data types and built-in timingtask managementMulti table joint queryFront and rear end separation deploymentInterface permissionsOperation recordMultiple data sourcesMail systemBlack and white listAnd many other practical functions can be used by directly calling the API.

Kill the front! 3 minutes pure Java annotation to build a management system

Say in the back

EruptThe advantages of the framework are obvious, fast, efficient, easy to use, and very friendly to novices. However, in the actual production environment, I just use it to do some data management of configuration dictionary.

Because its deep encapsulation makes development simple and efficient, but for systems with relatively complex business and highly customized,EruptThe framework is inadequate. More importantly, its community is not particularly active. After all, it is a niche framework.

However, technology has always served the business, if your business andEruptMatch your temperament. Don’t hesitate to use it!


Hundreds of various technical e-books were sorted out and sent to our friends. Pay attention to the official account.Something inside the programmer】Reply【666】Collect by yourself. We have set up a technical exchange group with some partners to discuss technology and share technical materials, so as to learn and progress together. If you are interested, join us!

Kill the front! 3 minutes pure Java annotation to build a management system

This work adoptsCC agreement, reprint must indicate the author and the link to this article

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 […]