Skip to content

Commit e0bff68

Browse files
committed
feat: Spring Boot 整合 Erupt 开源企业后端管理开发框架案例(官方案例)
1 parent 39edb2c commit e0bff68

29 files changed

+1293
-0
lines changed

springboot-erupt/.erupt/generator.loaded

Whitespace-only changes.

springboot-erupt/.erupt/job.loaded

Whitespace-only changes.

springboot-erupt/.erupt/upms.loaded

Whitespace-only changes.

springboot-erupt/.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/

springboot-erupt/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 erupts
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

springboot-erupt/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
2+
<p align="center"><img src="https://www.erupt.xyz/demo/erupt.svg" height="150" alt="logo"/></p>
3+
<h1 align="center"> Erupt Framework &nbsp; 🚀 &nbsp; 框架演示代码 </h1>
4+
<h3 align="center">零前端代码,几行 Java 注解,搞定后台管理系统</h3>
5+
<h3 align="center"><a href="https://erupt.xyz" target="_blank">https://www.erupt.xyz</a></h3>
6+
7+
---
8+
9+
<p align="center">
10+
<a href="https://www.erupt.xyz" target="_blank"><img src="https://img.shields.io/badge/Erupt-Framework-brightgreen" alt="Erupt Framework"></a>
11+
<a href="https://www.oracle.com/technetwork/java/javase/downloads/index.html"><img src="https://img.shields.io/badge/JDK-8+-green.svg" alt="jdk 8+"></a>
12+
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-Apache%202-blue" alt="license Apache 2.0"></a>
13+
<a href="https://gitee.com/erupt/erupt"><img src="https://gitee.com/erupt/erupt/badge/star.svg?theme=dark" alt="Gitee star"></a>
14+
<a href="https://gitee.com/erupt/erupt"><img src="https://gitee.com/erupt/erupt/badge/fork.svg?theme=dark" alt="Gitee fork"></a>
15+
<a href="https://github.com/erupts/erupt"><img src="https://img.shields.io/github/stars/erupts/erupt?style=social" alt="GitHub stars"></a>
16+
<a href="https://github.com/erupts/erupt"><img src="https://img.shields.io/github/forks/erupts/erupt?style=social" alt="GitHub forks"></a>
17+
<a href="https://github.com/erupts/erupt"><img src="https://img.shields.io/github/repo-size/erupts/erupt" alt="size"></a>
18+
</p>
19+
20+
<p align="center">
21+
<a href="https://github.com/erupts/erupt">Github 仓库</a> &nbsp; | &nbsp;
22+
<a href="https://gitee.com/erupt/erupt">Gitee 仓库</a> &nbsp; | &nbsp;
23+
<a href="https://www.erupt.xyz" target="_blank">官方网站</a> &nbsp; | &nbsp;
24+
<a href="https://www.yuque.com/yuepeng/erupt/bdiq6o" target="_blank">贡献指南</a> &nbsp; | &nbsp;
25+
<a href="https://www.erupt.xyz/demo" target="_blank">在线体验</a> &nbsp; | &nbsp;
26+
<a href="https://www.yuque.com/yuepeng/erupt" target="_blank"><b>使用文档</b></a>
27+
</p>
28+
29+
<p align="center">
30+
QQ交流群:<a href="https://jq.qq.com/?_wv=1027&k=MCd4plZ0">821389129 🔥</a>
31+
</p>
32+
33+
### 使用方法:
34+
1. 前往 src/main/resources/application.yml 修改数据库连接配置
35+
2. 前往 src/main/java/DemoApplication 运行main方法即可
36+
37+
默认用户名密码: erupt / erupt
38+
39+
40+
### 将model下的类添加到菜单:
41+
42+
启动成功后,前往系统管理 → 菜单维护 → 新增,将已定义好的演示类添加到菜单中,填写数据如下:
43+
44+
| 菜单名称 | 菜单类型 | 类型值(类名) | 描述 |
45+
| ---- | ---- | ---- | ---- |
46+
| 入门示例 | 表格 | Simple | |
47+
| 文章管理 | 表格 | Article | |
48+
| 树示例 || TreeView | |
49+
| 组件示例 | 表格 | Component | 各类组件与事件代理使用方法 |
50+
| 复杂示例 | 表格 | Complex | 动态下拉列表与定义按钮等功能 |
51+
| 多行操作 | 功能按钮 | ComplexBtn | 控制 Complex '多行操作'的按钮权限,状态选隐藏 |
52+
| 自定义页面 | 模板 | erupt.html | 自定义页面 |
53+
| 链接 | 链接 | https://www.erupt.xyz | |
54+
| 新页面 | 新页签 | https://github.com/erupts/erupt | |
55+
56+
57+
**配置项说明**
58+
> 编码:确保唯一即可,建议是字母
59+
60+
61+
### 常见问题
62+
+ 如果图片上传失败请前往 application.yml 修改 erupt.uploadPath 配置
63+
+ 地图组件无法使用请前往 app.js 修改 eruptSiteConfig.amapKey 的值
64+
+ 继承HyperModel的作用,可帮助管理,创建时间,修改时间,修改人,更新人字段
65+
66+
### 目录说明
67+
```lua
68+
erupt-example
69+
├── src
70+
├── main.java -- 源码
71+
└── com.example.demo -- 包名
72+
├── ExampleApplication -- 入口类
73+
├── dao
74+
└── ArticleRepository -- 使用对文章对象的增删改查封装,使用方式与Mybatis-Plus大同小异,具体调用详见 ExampleApplicationTests
75+
├── handler
76+
├── AutoCompleteHandlerImpl -- 自动完成示例
77+
├── ComponentDataProxy -- 事件代理代码示例
78+
└── OperationHandlerImpl -- 操作按钮处理类
79+
└── model
80+
├── Article -- 文章示例
81+
├── Complex -- 复杂示例
82+
├── ComplexOperator -- 复杂示例按钮表单
83+
├── Componen -- 组件示例
84+
├── Simple -- 基本示例
85+
└── TreeView -- 树视图
86+
├── test.java -- 测试包
87+
└── com.example.demo -- 包名
88+
└── ExampleApplicationTests -- 包含调用 ArticleRepository 演示代码,直接点击运行单个方法即可
89+
└── resources -- 配置包
90+
├── application.yml -- 后台配置
91+
├── tpl
92+
├── erupt.html -- 自定义页面
93+
└── public
94+
├── app.css -- 前端样式
95+
├── app.js -- 前端配置
96+
└── home.html -- 首页样式
97+
└── pom.xml -- 依赖配置
98+
```
99+
100+
101+
# ⚠ 一定得记住:
102+
1. 修改数据库配置,直接启动项目,项目涉及到的MySQL数据库表将使用JPA自动生成。

springboot-erupt/pom.xml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.4.1</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
12+
<packaging>war</packaging>
13+
14+
<groupId>com.example</groupId>
15+
<artifactId>erupt-example</artifactId>
16+
<version>0.0.1-SNAPSHOT</version>
17+
<description>SpringBoot 整合 Erupt 后台管理快速开发框架(Erupt官方提供的起步案例) project for Spring Boot</description>
18+
19+
<properties>
20+
<java.version>1.8</java.version>
21+
<erupt.version>1.6.5</erupt.version>
22+
</properties>
23+
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-starter</artifactId>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-test</artifactId>
33+
<scope>test</scope>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>mysql</groupId>
38+
<artifactId>mysql-connector-java</artifactId>
39+
</dependency>
40+
41+
<!--用户权限管理-->
42+
<dependency>
43+
<groupId>xyz.erupt</groupId>
44+
<artifactId>erupt-upms</artifactId>
45+
<version>${erupt.version}</version>
46+
</dependency>
47+
<!--接口数据安全-->
48+
<dependency>
49+
<groupId>xyz.erupt</groupId>
50+
<artifactId>erupt-security</artifactId>
51+
<version>${erupt.version}</version>
52+
</dependency>
53+
<!--后台WEB界面-->
54+
<dependency>
55+
<groupId>xyz.erupt</groupId>
56+
<artifactId>erupt-web</artifactId>
57+
<version>${erupt.version}</version>
58+
</dependency>
59+
<!--任务管理模块-->
60+
<dependency>
61+
<groupId>xyz.erupt</groupId>
62+
<artifactId>erupt-job</artifactId>
63+
<version>${erupt.version}</version>
64+
</dependency>
65+
<!--自定义模板页面模块-->
66+
<dependency>
67+
<groupId>xyz.erupt</groupId>
68+
<artifactId>erupt-tpl</artifactId>
69+
<version>${erupt.version}</version>
70+
</dependency>
71+
<!--代码生成器模块-->
72+
<dependency>
73+
<groupId>xyz.erupt</groupId>
74+
<artifactId>erupt-generator</artifactId>
75+
<version>${erupt.version}</version>
76+
</dependency>
77+
78+
<dependency>
79+
<groupId>org.springframework.boot</groupId>
80+
<artifactId>spring-boot-starter-tomcat</artifactId>
81+
<scope>provided</scope>
82+
</dependency>
83+
</dependencies>
84+
85+
<build>
86+
<plugins>
87+
<plugin>
88+
<groupId>org.springframework.boot</groupId>
89+
<artifactId>spring-boot-maven-plugin</artifactId>
90+
</plugin>
91+
</plugins>
92+
</build>
93+
94+
<repositories>
95+
<repository>
96+
<id>nexus-aliyun</id>
97+
<name>nexus-aliyun</name>
98+
<url>http://maven.aliyun.com/nexus/content/repositories/central</url>
99+
<releases>
100+
<enabled>true</enabled>
101+
</releases>
102+
<snapshots>
103+
<enabled>false</enabled>
104+
</snapshots>
105+
</repository>
106+
</repositories>
107+
108+
</project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.example.demo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.autoconfigure.domain.EntityScan;
6+
import org.springframework.boot.builder.SpringApplicationBuilder;
7+
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
8+
import org.springframework.context.annotation.ComponentScan;
9+
import xyz.erupt.core.annotation.EruptScan;
10+
11+
import java.awt.*;
12+
import java.io.IOException;
13+
import java.net.URI;
14+
import java.net.URISyntaxException;
15+
16+
/**
17+
* @author drew
18+
*/
19+
@SpringBootApplication
20+
@ComponentScan({"xyz.erupt", "com.example.demo"}) // ↓ xyz.erupt必须有
21+
@EntityScan({"xyz.erupt", "com.example.demo"}) // ↓ 如果包名com.example.demo有变化
22+
@EruptScan({"xyz.erupt", "com.example.demo"}) // → 要修改为变化后的包名
23+
public class ExampleApplication extends SpringBootServletInitializer {
24+
25+
public static void main(String[] args) throws URISyntaxException, IOException {
26+
SpringApplication.run(ExampleApplication.class, args);
27+
System.setProperty("java.awt.headless", "false");
28+
Desktop.getDesktop().browse(new URI("http://localhost:8080"));
29+
System.err.println("详细使用方法,请阅读:README.md");
30+
}
31+
32+
/**
33+
* 打WAR包的配置
34+
* @param application
35+
* @return
36+
*/
37+
@Override
38+
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
39+
return application.sources(ExampleApplication.class);
40+
}
41+
42+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.example.demo.controller;
2+
3+
import com.example.demo.dao.ArticleRepository;
4+
import com.example.demo.model.Article;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
import java.util.List;
10+
11+
/**
12+
* @author drew
13+
*/
14+
@RestController
15+
public class TestController {
16+
17+
@Autowired
18+
private ArticleRepository articleRepository;
19+
20+
@RequestMapping("/test")
21+
public List<Article> testArticle() {
22+
return articleRepository.findAll();
23+
}
24+
25+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.example.demo.dao;
2+
3+
import com.example.demo.model.Article;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
6+
import java.util.List;
7+
8+
/**
9+
* 直接继承 JpaRepository 就有了增删改查等能力,该功能由 spring-data-jpa 提供
10+
* 泛型说明:Article 实体类对象 Long 主键数据类型
11+
*
12+
* @author liyuepeng
13+
* @date 2021/1/6 18:31
14+
*/
15+
public interface ArticleRepository extends JpaRepository<Article, Long> {
16+
17+
//方法名称必须要遵循驼峰式命名规则,findBy(关键字)+属性名称(首字母大写)+查询条件(首字母大写)
18+
List<Article> findByTitle(String title); //根据标题查找文章
19+
20+
}

0 commit comments

Comments
 (0)