In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to build a Java management system", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to build a Java management system.
Erupt a general background management framework, it is said to have ultra-low code, zero front-end code, zero CURD operation, no need to build tables, pure Java annotation development and other features, claim to be able to build a complete background management system in three minutes.
Well, it sounds like a lot of criticism, whether it is so magical or not, let's use it and feel it.
First of all, let's set up the environment. Erupt currently supports Java version 1.8.0 and above, Spring Boot version 2.0 and above.
Set up easy
Pom.xml introduces the necessary jar packages
Org.springframework.boot spring-boot-starter mysql mysql-connector-java xyz.erupt erupt-upms 1.6.7 xyz.erupt erupt-security 1.6.7 Xyz.erupt erupt-web 1.6.7 org.springframework.boot spring-boot-starter-tomcat compile
Application.yml file as long as the simple configuration of the data source, prepare a database in advance, when it comes to the database here I would like to say a small episode.
When I submitted the case code in Github (https://github.com/chengxy-nds/Springboot-Notebook), the cloud database account was leaked because I didn't pay much attention to the sensitive information. Recently, I found that a partner had already run a project on the database. I took a closer look at the data structure and found that it looked like a complete project.
This library itself is a test library for me to run the demo case, in order to enable my partners to spend more time on the technical points of the case study and reduce the untechnical trivia of building the environment.
Found that here I did not change the password, nor deleted their library, if you want to use, continue to use, but play, play, you can not tamper with your data! It is not good to affect other people's 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: xxxx@qq.com password: xxxxxxx host: smtp.qq.com properties: mail.smtp.ssl.auth: true Mail.smtp.ssl.enable: true mail.smtp.ssl.required: trueserver: port: 8888
After saying something beside the point, let's continue to do it.
As a matter of fact, the environment of Erupt is finished, er, this is it?
We didn't do anything, the project was an empty shell, and we didn't write a single line of code, as if we didn't even build a table.
Don't worry, let's start the project first and see that the console prints out a lot of build table statements and insert statements, because the underlying application of the Erupt framework JPA persistence, preset to create some system tables and data.
Note: the Erupt preset table will only be built once when the project starts for the first time. If you want to recreate it, delete the .Erupt file (usually in the workspace of the project) and get the file location.
System.getProperty ("user.dir")
Look at the 16 system tables created in the database, in which the eroomupms _ user table is the user table. By default, there is only one administrator account, and the user name and password are all erupt.
Then we visited http://127.0.0.1:8888/ to see what the effect was, and there was a complete login page.
Log in directly with the user name and password above, erupt has achieved complete permission control and other functions in advance, but here we have hardly written any code, it is all encapsulated by the framework, menu data are all dynamically obtained from the database, and a basic background management system is built, which is a little wow.
Interesting page
So here comes the question? What if you want to customize the page?
At the beginning, we said that erupt is zero front-end code, all based on Java annotations, and then write a simple page experience with Java annotations.
Erupt has two core annotations @ Erupt,@EruptField
@ Erupt Annotation Decoration class, which represents defining a page
@ EruptField annotation decorated field, representing the field name displayed on the page
@ Power annotation controls whether to operate buttons, add, delete, change, check, import, export, etc.
@ Search annotation indicates that the field is a search condition
The @ Table annotation indicates that the page takes the table corresponding to the data. If it is not set, the page will automatically create a table name that matches the class name according to the class field value when the page is initialized for the first time.
There are many types of notes, not enumerated one by one, more of them go to the official website to see: https://www.erupt.xyz
Below we define a Student class, plus the @ Erupt,@EruptField annotation, so that even if the page and elements are finished, it is a bit subversive.
/ * * @ Erupt comments are decorated on the class @ EruptField annotations are decorated on fields * other annotations are Jpa annotations * / @ Getter@Setter@Erupt (name = "student form", power = @ Power (importable = true, export = true)) @ Entity//@Table (name = "t_student") public class Student extends BaseModel {@ EruptField (views = @ View (title = "student name"), edit = @ Edit (title = "student name", 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 = "student age"), edit = @ Edit (title = "student age", notNull = true) private String studentAge @ Lob @ EruptField (views = @ View (title = "student gender"), edit = @ Edit (title = "student gender", notNull = true) private String studentSex @ EruptField (views = @ View (title = "Review status"), edit = @ Edit (title = "Review status", notNull = true, boolType = @ BoolType (trueText = "pass", falseText = "fail"), search = @ Search) private Boolean status;}
But at this time, the newly created page will not be displayed, and we need to manually do a mapping relationship, customize a menu in the menu maintenance, and the type value must be the newly created class name Student.
After saving and refreshing, we will see that our new page appears, and the function of the page is very complete, and the basic operation, query, import and export functions are realized automatically.
A new student information is added to the page, and there are more records in the corresponding Student table, and the persistence process is done entirely by the framework.
Although the Erupt framework deeply encapsulates the front and back end code, it provides rich and flexible custom interfaces to meet our personalized needs.
For example, when we enter new student information, if we want to block the students whose name is Zhang San, we can dataProxy the button function of the page to achieve custom logic, and we can achieve the corresponding method for which button agent. For example, beforeAdd and afterAdd are the agents for the new button.
@ Getter@Setter@Erupt (name = "student form", dataProxy = {StudentDataProxy.class}, power = @ Power (importable = true) Export = true) @ Entity//@Table (name = "t_student") public class Student extends BaseModel {} public class StudentDataProxy implements DataProxy {@ Override public void beforeAdd (Student student) {/ / background field verification if ("Zhang San" .equals (student.getStudentName () {throw new EruptApiErrorTip ("the name is prohibited as Zhang San!") ; @ Override public void afterAdd (Student student) {} @ Override public void afterUpdate (Student student) {} @ Override public void afterDelete (Student student) {}}
When we entered a classmate named Zhang San on the page, we successfully blocked it. There are many other similar functions, but here we will not give examples one by one. Look at the documents and read the documents.
If we want to develop the interface in the traditional way, we don't have to worry about conflicts with Erupt's page generation rules and won't be affected at all. Moreover, JPA is integrated into Erupt and a ready-made dao interface is provided. As long as you call the corresponding API, you can start development.
It doesn't matter if you don't want to write Java code by hand, Erupt also provides a code generator to customize the Java class name and field name, you can generate code, just copy it.
Speaking of which, I only introduced the basic features of Erupt, mainly to let my friends know that there is such an agile weapon.
Not only that, it also supports a wealth of data types, built-in, such as scheduled task management, multi-table joint query, front and rear separation and deployment, interface permissions, operation records, multiple data sources, mail system, blacklist and whitelist and many other practical functions, all of which can be used by calling API directly.
At this point, I believe you have a deeper understanding of "how to build a Java management system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.