🍅 Author’s home page: Java Li Yangyong

🍅 Introduction: Java domain quality creator 🏆, Java Li Yang Yong public number author ✌ resume templates, learning materials, interview questions library, technical mutual help

🍅 welcome to like 👍 collect ⭐ message 📝

Preface:

Recently, one of my classmates asked me to help him build a simple winery management system. So I found this open source framework to try it out. What is this project? It is a set of SpringBoot, MyBatis, Shiro in one of the standard project framework, let us free hands ✋ from now on. Whether it is used to learn technology or take private work/graduation/part-time money, are very good yo, suggest you collect, at the end of the article I give you the source code.

This is not too simple minutes can be done, ha ha, no nonsense, today to show you the use of an open source framework to write a bar

Key features of this open source project:

  • This framework uses SpringBoot, MyBatis, Shiro framework, the development of a set of authority system, very low threshold, use. At the beginning of the design, we also pay great attention to security. We can learn to use and use simple enterprise systems for ourselves, which makes our development very simple.
  • Flexible permission control, can control the page or button, meet most of the permission requirements, flexible control permissions according to the administrator
  • Perfect department management and data authority, through annotations to achieve data authority control, specific to the front-end code
  • Perfect XSS defense and script filtering, completely eliminate XSS attacks
  • Supports mainstream databases such as MySQL, Oracle, SQL Server, and PostgreSQL
  • It is recommended to deploy a cloud server

Built-in function template:

User management: Users are system operators. This function is used to configure system users. Department management: Configure the system organization (company, department, and group) and display the data permission in a tree structure. Position management: Configures the positions of system users. Menu management: configure system menu, operation permission, button permission identification, etc. Role management: Role menu permission assignment and role setting Data scope permission division by organization. Dictionary management: Maintenance of fixed data that is often used in the system. Parameter management: Dynamically configure common system parameters. Announcements: System announcements are published and maintained. Operation logs: Record and query system operation logs. Record and query system exception information. Login log: System login log query contains login exceptions. Online user: monitors the status of active users in the current system. Scheduled task: Online (add, modify, or delete) task scheduling includes execution result logs. Code generation: The generation of front-end and back-end code (Java, HTML, XML, SQL) supports CRUD download. System interface: Automatically generate relevant API interface documents according to the business code. Service monitoring: Monitors the current system CPU, memory, disk, and stack information. Cache monitoring: System cache information query, command statistics, etc. Online builder: Drag form elements to generate the corresponding HTML code. Connection pool monitoring: Monitors the current system database connection pool status and analyzes SQL to find out system performance bottlenecks.

Project Introduction:

The project is actually divided into four modules:

  • Renren-common is a public module, and other modules are introduced in the form of JAR packages, which mainly provide some tool classes, as well as the entity, mapper, DAO and Service services common to renren-admin and Renren-API modules, preventing a function from being coded repeatedly.
  • Renren-admin is the background module, which is also the core of the system. It is used to develop the background management system. It can be packaged as jar and deployed to run on the server, or packaged as war and run in Tomcat8.5+ container.
  • Renren-api is an interface module, mainly to simplify APP development, such as: It provides interfaces for wechat applets, IOS and Android. It has a separate user system, which is not shared with the renren-admin user table, because the renren-admin user table stores internal accounts of enterprises, and has the background administrator permission to log in to the background management system. But renren-API user table is stored in our real users, do not have the permission to log in the background management system. Renren-api mainly realizes the functions of user registration, login, interface authorization authentication, access to login users and so on, providing an elegant solution for the safe invocation of APP interface, thus simplifying APP interface development.
  • Renren-generator is a code generator module that can generate code for adding, modifying, deleting, querying, exporting and other operations, including entity, mapper, DAO, service, controller, page and other codes, simply by creating a table structure in the MySQL database. Project development artifact.

As I personally do not use API/wechat applets, IOS and Android interface services and generator code generator modules, I can delete and add modules according to the actual situation

Local deployment projects:

Download address:

git clone https://gitee.com/renrenio/renren-security.git
Copy the code

  • Environment Requirements JDK1.8, Tomcat8.5+, MySQL5.5+
  • Download renren-security source code with git as follows:

  • Create database renren_security with utF-8 encoding
  • Execute database scripts, such as MySQL database, execute db/mysql. SQL file to initialize data
  • Modify application-dev.yml to change the database account and password
spring: datasource: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/renren-chateau? useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: 123456 initial-size: 10 max-active: 100 min-idle: 10 max-wait: 60000 pool-prepared-statements: true max-pool-prepared-statement-per-connection-size: 20 time-between-eviction-runs-millis: #validation-query: SELECT 1 FROM DUAL test-while-idle: SELECT 1 FROM DUAL test-while-idle: SELECT 1 FROM DUAL test-while-idle: SELECT 1 FROM DUAL test-while-idle: SELECT 1 FROM DUAL test-while-idle: true test-on-borrow: false test-on-return: false stat-view-servlet: enabled: true url-pattern: /druid/* #login-username: admin #login-password: admin filter: stat: log-slow-sql: true slow-sql-millis: 1000 merge-sql: false wall: config: multi-statement-allow: true ## # datasource: # slave1: # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver # url: jdbc:sqlserver://localhost:1433; DatabaseName=renren_security # username: sa # password: 123456 # slave2: # driver-class-name: org.postgresql.Driver # url: jdbc:postgresql://localhost:5432/renren_security # username: renren # password: 123456Copy the code

Set blocking permit:

Static resource files as well as login and Swagger – UI interface documents are allowed

@Bean("shiroFilter") public ShiroFilterFactoryBean shiroFilter(SecurityManager securityManager) { ShiroFilterFactoryBean  shiroFilter = new ShiroFilterFactoryBean(); shiroFilter.setSecurityManager(securityManager); shiroFilter.setLoginUrl("/login.html"); shiroFilter.setUnauthorizedUrl("/"); Map<String, String> filterMap = new LinkedHashMap<>(); filterMap.put("/swagger/**", "anon"); filterMap.put("/v2/api-docs", "anon"); filterMap.put("/swagger-ui.html", "anon"); filterMap.put("/webjars/**", "anon"); filterMap.put("/swagger-resources/**", "anon"); filterMap.put("/statics/**", "anon"); filterMap.put("/login.html", "anon"); filterMap.put("/sys/login", "anon"); filterMap.put("/favicon.ico", "anon"); filterMap.put("/captcha.jpg", "anon"); filterMap.put("/**", "authc"); shiroFilter.setFilterChainDefinitionMap(filterMap); return shiroFilter; }Copy the code

Project launch:

  • IO operation. Renren. AdminApplication. Java main method, can start the renren – admin projects
  • The access path of the project: http://localhost:8080/renren-admin

  • Account password: admin/admin
  • Swagger path: http://localhost:8080/renren-admin/swagger/index.html
  • Swagger annotation path: http://localhost:8080/renren-admin/swagger-ui.html

This is what it looks like after a slight modification

Before modification:

After transforming:

Add some business tables and delete to hide some unnecessary function modules

Core technologies:

SpringBoot is an out-of-the-box framework that provides a variety of default configurations to simplify project configuration. Make our Spring application lighter and faster to get started. It can be run by executing the main function in the main program. You can also package your application as jar and run your Web application using Java-jar. It follows the principle of “convention over configuration” and requires very little configuration to use SpringBoot, most of the time going straight to the default configuration. It also seamlessly integrates with Spring Cloud’s microservices.

The Spring Boot2.x environment must be JDK8 or later, and the server Tomcat8 or later

advantages

  • Make coding easy: Annotations are recommended.
  • Make configuration easy: The ability to automatically configure, quickly integrate new technologies without the need for redundant code generation and XML configuration
  • Easy deployment: Web containers such as Tomcat, Jetty, and Undertow are embedded without deployment as a WAR package
  • Make monitoring easy: Provide runtime application monitoring
  • Make integration easy: configuration-free integration with mainstream development frameworks.
  • Make development easier: greatly improve the development of rapid build projects, deployment efficiency.

Spring Security Security control

Spring Security is a Security framework that provides declarative secure access control solutions for Spring-based enterprise applications.

2, function Authentication, is the user login Authorization, determine what permissions users have, what resources can access security protection, cross-site scripting attack, session attack is very easy to use with Spring

3. Differences between Spring Security and Shiro

The same

Authentication 2 Authorization 3 Encryption 4 Session management 5 Cache support 6 rememberMe

The difference between

Advantages:

1. Spring Security is developed based on Spring. If the project uses Spring as the basis, it will be more convenient to do permissions with Spring Security. Shiro needs to integrate with Spring for development. 2. Spring Security has more features than Shiro, such as Security protection. 3

Disadvantages:

1) Shiro is easier to configure and use than Spring Security, and 2) Shiro is less dependent on any framework or container and can run independently. Spring Security relies on the Spring container

Today recommend this SpringBoot open source project or relatively good, the project is fast development scaffolding, code quality is also good, suitable for doing their own learning technology or their ownPart-time private work ordersIt is possible to yo, like a friend to point a three-link support yo

Get the source code:

In general, the open source project function is relatively excellent, suitable for everyone to learn reference use

Update Java article 49/100 days, you can like, favorites, follow, comment on me,

Check out the blogger’s home page for more