This article is available at github.com/chengxy-nds…

Hello, I’m Rich

Recently, I came into contact with a new project and found that it uses an interesting framework, which can be said to realize my dream when I just started the industry. Therefore, I have been sharing it with you without stopping.

Contact I began to work in the project hasn’t done before and after the end of the separation, often need to maintain the back-end page, sometimes feel like naturally would not be suited to the front, if you let me study the backend technology, watching a middleware source, analyzing what framework underlying principle, the problem is not big, occasionally get a JS can also. If you ask me to write a CSS style, that is a hell of a lot of fun. I don’t know if there is one like me.

Today to introduce the framework directly do not need to write a page, not to say more, let’s go straight to the theme

Erupt is a universal backend management framework that boasts ultra-low code load, zero front-end code, zero CURD operations, no tables, pure Java annotation development, and claims to be able to build a complete backend management system in three minutes.

Uh ~ sounds like a lot of flow batch, in the end is not so magical, let’s use it to feel.

To start, restraint currently supports Java version 1.8.0 and above and Spring Boot version 2.0 and above.

Set up easy

Pom.xml introduces the necessary JAR packages

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <! -- User rights Management -->
        <dependency>
            <groupId>xyz.erupt</groupId>
            <artifactId>erupt-upms</artifactId>
            <version>1.6.7</version>
        </dependency>
        <! -- Interface data security -->
        <dependency>
            <groupId>xyz.erupt</groupId>
            <artifactId>erupt-security</artifactId>
            <version>1.6.7</version>
        </dependency>
        <! -- Background WEB interface -->
        <dependency>
            <groupId>xyz.erupt</groupId>
            <artifactId>erupt-web</artifactId>
            <version>1.6.7</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>compile</scope>
        </dependency>
    </dependencies>
Copy the code

The application. Yml file is a simple configuration of the data source, and prepare a database ahead of time.

In making before I submit case code (https://github.com/chengxy-nds/Springboot-Notebook), because not too pay attention to the screen sensitive information, lead to cloud leaked the database account, Recently, I found that some of my friends have been running projects on the database. After a careful look at the data structure in the database, I found it was like a graduation project.

The library itself is a test library for me to run demo cases, so that my friends can spend more time on the technical points of the case study and reduce the trivial matters of setting up the environment without technical content.

Discover to discover, here I did not change password, also did not delete their library, if you want to continue to use, but play to play, play to play, you can not mess with not your data! It’s not good to interfere with other people’s learning.

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: xxxx@qq.com
    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
Copy the code

A little digression, let’s move on

To emerge from restraint here, that’s it, eh?

We didn’t do anything. The project was an empty shell. We didn’t write a single line of code.

Before we start the project, we see a lot of table building and insert statements printed on the console. This is because THE Erupt framework uses JPA persistence to precreate some system tables and data.

Note: Erupt presets are built only once with the first startup of the project and must be removed if you want to recreate them. Erupt files (normally in the project workspace), method of obtaining file location

System.getProperty("user.dir")
Copy the code

The e_upMS_user table is a user table. By default, there is only one administrator account. The user name and password are erupt.

Then we went to http://127.0.0.1:8888/ to see what it looked like, and there was a full login page.

To emerge from Restraint up front, with the above user name and password, we already had full access control up front, but we didn’t write any code, it was all wrapped up in the framework, the menu data was all dynamically retrieved from the database, and a basic background management system was built. It was amazing.

Interesting pages

So the question is, right? What if you want to customize your page?

Erupt is zero front-end code, all based on Java annotations, as we explained at the beginning, and I’ll try out a simple page using Java annotations.

To erupt violently has two core notes @ erupt, @EruptField

  • @EruptAn annotation decorates a class that defines a page
  • @EruptFieldAn annotation decorates a field that represents the name of the field displayed on the page
  • @PowerAnnotations control whether to operate buttons, add, delete, modify, search, import, export, etc
  • @SearchAnnotations indicate that the field is a search criterion
  • @TableAnnotation indicates the table to which the page fetched data. If this parameter is not set, the page will automatically create a table with the same class name based on the class field value when it is initialized for the first time.

Annotation types are more, not a list, more of their own to the official website: https://www.erupt.xyz

So now we’re going to define a Student class, @Erupt, @EruptField, so that when we’re done with the page and the elements, isn’t that a little bit subverting?

/* * @erupt caps on classes, @eruptfield caps on fields * all other caps are Jpa caps */
@Getter
@Setter
@erupt (name = "Erupt ", power = @power (importable = true, export = true))
@Entity
//@Table(name = "t_student")
public class Student extends BaseModel {

    @eruptfield (views = @view (title = "limit "), edit = @edit (title =" limit ", notNull = true; search = @Search(vague = true)) )
    private String studentName;

    @eruptfield (views = @view (title = "class "), edit = @edit (title =" class ", notNull = true)
    private String studentClass;

    @eruptfield (views = @view (title = "limit "), edit = @edit (title =" limit ", notNull = true)
    private String studentAge;

    @Lob
    @eruptfield (views = @view (title = "gender "), edit = @edit (title =" gender ", notNull = true)
    private String studentSex;

    @eruptfield (views = @view (title = "limit status "), edit = @edit (title =" limit status ", notNull = true; BoolType = @boolType (trueText = "pass ", falseText =" fail "), search = @search)
    private Boolean status;
}
Copy the code

But at this time, the newly created page will not be displayed, we also need to manually make a mapping relationship, in the menu maintenance to define a menu, the type value must be the name of the newly created class Student.

Save and refresh will see our new page appeared, and the function of the page is very complete, basic operations, query, import, export functions are automatically realized.

A new Student is added to the page, and a new record is added to the Student table. The persistence process is completely handled by the framework.

Although the Erupt framework deeply encapsulates the front and back end code, it provides a rich and flexible custom interface to meet our individual needs.

For example, when we input new student information, we want to shield students whose name is Zhang SAN. We can do dataProxy for page button function to realize customized logic, and realize corresponding method for which button proxy, such as beforeAdd and afterAdd is the proxy for new buttons.

@Getter
@Setter
@erupt (name = "student table ",dataProxy = {StudentDataProxy. Class}, power = @power (importable = true, export = true))
@Entity
//@Table(name = "t_student")
public class Student extends BaseModel {}public class StudentDataProxy implements DataProxy<Student> {

    @Override
    public void beforeAdd(Student student) {
        // background field verification
        if ("Zhang".equals(student.getStudentName())) {
            throw new EruptApiErrorTip("Name is forbidden for Zhang SAN!"); }}@Override
    public void afterAdd(Student student) {}@Override
    public void afterUpdate(Student student) {}@Override
    public void afterDelete(Student student) {}}Copy the code

When we enter the name of zhang SAN in the page, the successful shielding. There are many other similar functions, here is not an example, look at the document look at the document ~

If we want to develop our interfaces the traditional way, we won’t be affected by the Erupt page-generation rules. Erupt also integrates internally with JPA and provides a ready-made DAO interface that can be developed by calling the corresponding API.

If you don’t want to write Java code by hand, Erupt also provides a code generator for custom Java class and field names that you can copy.

To emerge violently from this restraint I have introduced only the basic characteristics of restraint, mainly to show you that there is an Erupt limit.

Not only that, it also supports rich data types, built-in such as scheduled task management, multi-table joint query, front-end and back-end separated deployment, interface permissions, operation records, multi-data sources, mail system, blacklist and whitelist and many other practical functions, can be used directly call API.

Said behind

The limitations of the Erupt framework are obvious: it’s fast, efficient, easy to use, and fairly novice friendly, but IN a production environment I only use it for some configuration dictionary data management.

While its depth of packaging makes development easy and efficient, the Erupt framework was inadequate for more complex, highly customized systems, and, crucially, its community was not particularly active. It was a niche framework.

However, technology has always been in the service of the business, and if your business matches your Erupt temperament, don’t hesitate to use it!


Sorted out hundreds of various kinds of technical e-books, there is a need for the students public number [programmer point matter] within the reply [666] self. The technology group is almost full, want to enter the students can add my friend, and the big guys blow technology together.