

恕我直言,有了这款 IDEA 插件,你可能只需要写 30% 的代码。。。
source link: http://mp.weixin.qq.com/s?__biz=MzAxMTg2MjA2OA%3D%3D&%3Bmid=2649849063&%3Bidx=2&%3Bsn=c027e3fcf25b5bde7dd599e9239aeb82
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

来源: jianshu.com/p/e4192d7c6844
Easycode是idea的一个插件,可以直接对数据的表生成entity,controller,service,dao,mapper,无需任何编码,简单而强大。
1、安装(EasyCode)
我这里的话是已经那装好了。
-
建议大家在安装一个插件,叫做Lombok。Lombok能通过注解的方式,在编译时自动为属性生成构造器、getter/setter、equals、hashcode、toString方法。出现的神奇就是在源码中没有getter和setter方法,但是在编译生成的字节码文件中有getter和setter方法。
2、建立数据库
-- ---------------------------- -- Table structure for user -- ---------------------------- DROP TABLE IF EXISTS `user`; CREATE TABLE `user` ( `id` int(11) NOT NULL, `username` varchar(20) DEFAULT NULL, `sex` varchar(6) DEFAULT NULL, `birthday` date DEFAULT NULL, `address` varchar(20) DEFAULT NULL, `password` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; SET FOREIGN_KEY_CHECKS = 1;
3、在IDEA配置连接数据库
-
在这个之前,新建一个Springboot项目,这个应该是比较简单的。
-
建好SpringBoot项目之后,如下图所示,找到这个Database
-
按照如下图所示进行操作:
-
然后填写数据库名字,用户名,密码。点击OK即可。这样的话,IDEA连接数据库就完事了。
4、开始生成代码
-
在这个里面找到你想生成的表,然后右键,就会出现如下所示的截面。
-
点击1所示的位置,选择你要将生成的代码放入哪个文件夹中,选择完以后点击OK即可。
-
勾选你需要生成的代码,点击OK。
-
这样的话就完成了代码的生成了,生成的代码如下图所示:
5、pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <!--热部署--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <!-- 这个需要为 true 热部署才有效 --> </dependency> <!--mybatis--> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.2</version> </dependency> <!-- mysql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.47</version> </dependency> <!--阿里巴巴连接池--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.0.9</version> </dependency>
6、Application.yml
server: port: 8089 spring: datasource: url: jdbc:mysql://127.0.0.1:3306/database?useUnicode=true&characterEncoding=UTF-8 username: root password: 123456 type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver mybatis: mapper-locations: classpath:/mapper/*Dao.xml typeAliasesPackage: com.vue.demo.entity
7、启动项目
在启动项目之前,我们需要先修改两个地方。
-
在dao层加上@mapper注解
-
在启动类里面加上@MapperScan("com.vue.demo.dao")注解。
-
启动项目
-
测试一下
---------- END ----------
推荐一个技术号
Github实验室,由国内985博士、硕士组成的团体运营。主要分享和研究业界开源项目,学习资源,程序设计,学术交流。 关注就无套路送你一份BAT算法大礼包。
有热门推荐:point_down:
点个在看少个 bug :point_down:
Recommend
-
47
-
53
-
55
我这么好看,怎么还是单身?
-
36
DVD-GAN,用 GAN 来生成 DVD 放映? 生成对抗网络已经能生成极其逼真的图像,甚至人类并都分不太出生成图的真假。像 StyleGAN 生成的人像,即使这些「人」并不存在,但生成结果已经逼真到让我们相信 Ta 曾来过地球。那...
-
29
EasyCode是基于IntelliJ IDEA开发的代码生成插件,支持自定义任意模板(Java,html,js,xml)。只要是与数据库相关的代码都可以通过自定义模板来生成。支持数据库类型与java类型映射关系配置。支持同时生成生成多张表的代码。每张表有独立...
-
37
一、基础代码准备 建立一个实体类,该实体类有五个属性。下面的代码使用了lombok的注解Data、AllArgsConstructor,这样我们就不用写...
-
33
一、回顾Stream管道流map的基础用法 最简单的需求:将集合中的每一个字符串,全部转换成大写! List<String> alpha = Arrays.asList("Monkey", "Lion", "Giraffe", "Lemur"); //不使用Stream管道流 List<...
-
25
一、粉丝的反馈 问:stream比for循环慢5倍,用这个是为了啥? 答:互联网是一个新闻泛滥的时代,三人成...
-
27
在我们对数组或者集合类进行操作的时候,经常会遇到这样的需求,比如: 是否包含某一个“匹配规则”的元素 是否所有的元素都符...
-
5
有了插件的ChatGPT,可能会成为未来互联网的唯一入口 • 2023-04-17...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK