1 Star 1 Fork 0

阿海 / AutoAdmin-JPA

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 5.33 KB
一键复制 编辑 原始数据 按行查看 历史
阿海 提交于 2019-07-10 23:44 . 补充提交

AutoAdmin, 高效Java服务端

特点

  • 快速实现增删改查 使用JPA语法省去了大部分SQL

  • 部署容易 内置Tomcat可直接运行,省去了配置tomcat的步骤

  • 配置简单 使用 application properties 替代了大部分XML的繁琐配置。

  • 漂亮的UI 使用LayUI效率和美观兼得。

  • 开发效率高 在本项目代码量相对较少的情况下提供了AutoCoding,只需要表SQL就能生成管理端的增删改查的大部分代码。

管理端功能

  • 菜单管理
  • 系统用户管理
  • 角色管理(权限)

项目环境要求

  • Java7及以上
  • Mysql5.5及以上

项目结构

├─src main
│ ├─java
│ │ ├─annotation 自定义注解
│ │ ├─base 基础类
│ │ │ └─BaseController.java
│ │ │ └─BaseEntity.java
│ │ │ └─BaseQuery.java
│ │ │ └─BaseResponse.java
│ │ │ └─BaseResponseList.java
│ │ │ └─BaseViewModel.java
│ │ ├─utils 工具类
│ │ │ └─DateUtil.java
│ │ │ └─MD5Util.java
│ │ ├─constants 常量
│ │ ├─controller 控制层,建议不同的业务包统一前缀,方便过滤和防止Controller重名。
│ │ ├─admin		管理端控制层
│ │ ├─entity 表实体类
│ │ ├─exception 异常
│ │ ├─interceptor 过滤器
│ │ ├─model  视图实体类
│ │ ├─repository 表操作类(JPA)
│ │ └─service 服务类
│ ├─resources
│ ├─static  资源文件
│ └─application.properties 项目主配置文件
│ └─application-dev.properties 开发环境配置文件
│ └─application-test.properties 测量环境配置文件
│ └─application-pro.properties 正式环境配置文件
│ └─log4j.properties 日志配置
│ └─messages.properties 消息定义
└─ README.md

快速入门

1.导入数据库

创建数据库,导入 dbscript/auto_admin.sql

2.修改配置文件

修改配置文件中的数据库连接、端口等信息 application.properties为主要配置文件,可修改文件中spring.profiles.active的值来指定不同环境:

  • application.properties 主配置文件,不随环境变化的的配置可以写在这里。
  • application-dev.properties 开发环境
  • application-test.properties 测试环境
  • application-pro.properties 正式环境

数据库连接信息

spring.datasource.url
spring.datasource.username
spring.datasource.password

application properties 官方文档,这块的内容比较多,有兴趣朋友的可以参考一下。

3. 运行

Maven构建成功后可看到Application可运行,后点击运行即可。(建议IDE使用Idea)

设置热部署 IDEA需要进行一项简单的设置,File > Settings > Build,Excutioni,Deployment > Compiler 将Build project automatically选上。

4、访问

根据自己配置的端口(server.port)访问http://localhost:端口 就可以看到AutoAdmin即成功。http://localhost:端口/admin/为管理端的登录入口。 默认账号和密码都是admin

参考文档

JPA支持语法

Keyword Sample JPQL snippet
And findByLastnameAndFirstname … where x.lastname = ?1 and x.firstname = ?2
Or findByLastnameOrFirstname … where x.lastname = ?1 or x.firstname = ?2
Is,Equals findByFirstname,findByFirstnameIs,findByFirstnameEquals … where x.firstname = ?1
Between findByStartDateBetween … where x.startDate between ?1 and ?2
LessThan findByAgeLessThan … where x.age < ?1
LessThanEqual findByAgeLessThanEqual … where x.age <= ?1
GreaterThan findByAgeGreaterThan … where x.age > ?1
GreaterThanEqual findByAgeGreaterThanEqual … where x.age >= ?1
After findByStartDateAfter … where x.startDate > ?1
Before findByStartDateBefore … where x.startDate < ?1
IsNull findByAgeIsNull … where x.age is null
IsNotNull,NotNull findByAge(Is)NotNull … where x.age not null
Like findByFirstnameLike … where x.firstname like ?1
NotLike findByFirstnameNotLike … where x.firstname not like ?1
StartingWith findByFirstnameStartingWith … where x.firstname like ?1(parameter bound with appended %)
EndingWith findByFirstnameEndingWith … where x.firstname like ?1(parameter bound with prepended %)
Containing findByFirstnameContaining … where x.firstname like ?1(parameter bound wrapped in %)
OrderBy findByAgeOrderByLastnameDesc … where x.age = ?1 order by x.lastname desc
Not findByLastnameNot … where x.lastname <> ?1
In findByAgeIn(Collection ages) … where x.age in ?1
NotIn findByAgeNotIn(Collection ages) … where x.age not in ?1
True findByActiveTrue() … where x.active = true
False findByActiveFalse() … where x.active = false
IgnoreCase findByFirstnameIgnoreCase … where UPPER(x.firstame) = UPPER(?1)

application properties 官方文档

Spring Boot

Spring Data JPA

交流加QQ群: 805405756

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/HarlanSong/AutoAdmin-JPA.git
git@gitee.com:HarlanSong/AutoAdmin-JPA.git
HarlanSong
AutoAdmin-JPA
AutoAdmin-JPA
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891