写点什么

Java Idea 插件 Easy Code

作者:孙永潮
  • 2022 年 7 月 22 日
  • 本文字数:28441 字

    阅读完需:约 93 分钟

Java Idea插件Easy Code

现在 Java 开发一般都基于 Spring Boot

大多在 pom 文件里也会添加 lombok 支持

需要的 Maven 依赖,每个团队的都大同小异,用自己团队的就行。

1. 首先 File —> Settings —> Plugins —> 下载并启用 Easy Code 插件
2. 需要 Idea 链接到数据源才能使用 Easy Code

IDEA 右侧 Date base —> 加 ”+“ 号—> Data Source

如果 Data Source 里有我们需要的数据库,就不用再配数据源了

如果没有我们需要的数据库,就参考下面链接配置一下(仅供参考)

idea链接数据源_独莫城的博客-CSDN博客_idea数据源

3. pom 文件

项目用的是 Spring Boot 框架

程序员必须知道每个依赖都是干啥的,最起码用到的时候,要知道复制粘贴哪个

  1. 用到 Easy Code 的子项目 pom.xml

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>business-gas-hudb-regulatory-platform-back</artifactId> <packaging>jar</packaging>
<name>business-gas-hudb-regulatory-platform-back</name> <description>business-gas-hudb-regulatory-platform-back</description>
<parent> <artifactId>gas-dependencies</artifactId> <groupId>com.gas</groupId> <version>1.0.0-SNAPSHOT</version> <relativePath>../gas-dependencies/pom.xml</relativePath> </parent>
<dependencies>
<!-- lombok支持 --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- core-monolithic-multi-data-source支持 --> <dependency> <groupId>com.gas</groupId> <artifactId>core-monolithic-multi-data-source</artifactId> <version>${project.parent.version}</version> <!-- <exclusions>--> <!-- <exclusion>--> <!-- <groupId>org.springframework.boot</groupId>--> <!-- <artifactId>spring-boot-starter-tomcat</artifactId>--> <!-- </exclusion>--> <!-- </exclusions>--> </dependency> <!-- 需要用tomcat测试时打开如下配置 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> </dependency> <!-- sa-token支持 --> <dependency> <groupId>cn.dev33</groupId> <artifactId>sa-token-spring-boot-starter</artifactId> </dependency> <dependency> <groupId>cn.dev33</groupId> <artifactId>sa-token-alone-redis</artifactId> </dependency> <!-- redis支持 --> <dependency> <groupId>cn.dev33</groupId> <artifactId>sa-token-dao-redis-jackson</artifactId> </dependency> <!-- 住建局唐山市燃气行业综合监管平台公用模块 --> <dependency> <groupId>com.gas</groupId> <artifactId>business-gas-hudb-regulatory-platform-common</artifactId> <version>${project.parent.version}</version> </dependency> <!--定时任务--> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>${quartz.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.4.4</version> <configuration> <fork>true</fork> <addResources>true</addResources> <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments> <mainClass>com.gas.BusinessGasHudbRegulatoryPlatformBackApplication</mainClass> <executable>true</executable> <layout>ZIP</layout> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build></project>
复制代码


  1. 常用的 common 的 pom.xml (这个就是上边 住建局唐山市燃气行业综合监管平台公用模块)

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>business-gas-hudb-regulatory-platform-common</artifactId> <packaging>jar</packaging>
<name>business-gas-hudb-regulatory-platform-common</name> <description>business-gas-hudb-regulatory-platform-common</description>
<parent> <artifactId>gas-dependencies</artifactId> <groupId>com.gas</groupId> <version>1.0.0-SNAPSHOT</version> <relativePath>../gas-dependencies/pom.xml</relativePath> </parent>
<dependencies> <dependency> <groupId>com.gas</groupId> <artifactId>gas-core</artifactId> <version>${gas-core.version}</version> </dependency> <!-- lombok支持 --> <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>${com.jcraft.version}</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>com.gas</groupId> <artifactId>extra-captcha-kaptcha</artifactId> <version>${project.parent.version}</version> </dependency> <dependency> <groupId>com.dm</groupId> <artifactId>Dm7JdbcDriver</artifactId> </dependency> <dependency> <groupId>com.gas</groupId> <artifactId>core-monolithic-multi-data-source</artifactId> <version>${project.parent.version}</version> </dependency> <!-- netty-websocket-spring-boot-starter支持 --> <dependency> <groupId>org.yeauty</groupId> <artifactId>netty-websocket-spring-boot-starter</artifactId> </dependency> <!-- extra-redis支持 --> <dependency> <groupId>com.gas</groupId> <artifactId>extra-redis</artifactId> <version>${project.parent.version}</version> </dependency> <dependency> <groupId>com.gas</groupId> <artifactId>extra-excel</artifactId> <version>${project.parent.version}</version> </dependency> </dependencies></project>
复制代码
  1. parent 的 pom.xml

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelVersion>4.0.0</modelVersion>
<groupId>com.gas</groupId> <artifactId>gas-dependencies</artifactId> <version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>gas-dependencies</name> <description>gas-dependencies</description>
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.2.RELEASE</version> <relativePath/> </parent>
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> <spring-cloud.version>Hoxton.SR8</spring-cloud.version> <spring-cloud-alibaba.version>2.2.5.RELEASE</spring-cloud-alibaba.version> <lombok.version>1.18.20</lombok.version> <mysql.version>8.0.23</mysql.version> <mybatis.version>3.5.6</mybatis.version> <mybatis-spring-boot-starter.version>2.1.4</mybatis-spring-boot-starter.version> <mybatisplus-spring-boot-starter.version>3.4.3.4</mybatisplus-spring-boot-starter.version> <mybatis-plus-generator.version>3.5.1</mybatis-plus-generator.version> <mybatis-plus-core.version>3.4.3.4</mybatis-plus-core.version> <mybatis-plus-annotation.version>3.4.3.4</mybatis-plus-annotation.version> <mybatis-plus-extension.version>3.4.3.4</mybatis-plus-extension.version> <p6spy.version>3.9.1</p6spy.version> <quartz.version>2.3.0</quartz.version> <dynamic-datasource-spring-boot-starter.version>3.4.1</dynamic-datasource-spring-boot-starter.version>
<clickhouse-jdbc.version>0.3.2</clickhouse-jdbc.version> <dm.version>1.8</dm.version>
<magic-script.version>1.6.0</magic-script.version> <magic-api-spring-boot-starter.version>1.7.0</magic-api-spring-boot-starter.version>
<fastjson.version>1.2.76</fastjson.version> <jackson-annotations.version>2.11.1</jackson-annotations.version> <jackson-databind.version>2.11.1</jackson-databind.version> <jackson-datatype-jsr310.version>2.11.1</jackson-datatype-jsr310.version> <netty.version>4.1.65.Final</netty.version> <netty-websocket-spring-boot-starter.version>0.11.0</netty-websocket-spring-boot-starter.version>
<hutool.version>5.7.15</hutool.version> <zxing.version>3.3.3</zxing.version> <oshi-core.version>5.7.5</oshi-core.version> <guava.version>30.1.1-jre</guava.version> <bitwalker.version>1.21</bitwalker.version> <commons-codec.version>1.13</commons-codec.version> <commons-io.version>2.6</commons-io.version> <commons-net.version>3.6</commons-net.version> <snakeyaml.version>1.28</snakeyaml.version> <pinyin4j.version>2.5.1</pinyin4j.version> <easyexcel.version>2.2.10</easyexcel.version> <com.jcraft.version>0.1.55</com.jcraft.version> <tlog.version>1.2.4</tlog.version>
<sa-token.version>1.30.0</sa-token.version> <sa-token-spring-aop.version>1.30.0</sa-token-spring-aop.version> <sa-token-dao-redis-jackson.version>1.30.0</sa-token-dao-redis-jackson.version> <sa-token-alone-redis.version>1.30.0</sa-token-alone-redis.version> <kaptcha.version>2.3.2</kaptcha.version>
<okhttp3.version>4.9.1</okhttp3.version> <feign-okhttp.version>11.1</feign-okhttp.version> <aio-core.version>1.5.8</aio-core.version>
<swagger-annotations.version>1.6.2</swagger-annotations.version> <knife4j.version>3.0.2</knife4j.version>
<aliyun-java-sdk-core.version>4.5.20</aliyun-java-sdk-core.version> <aliyun-java-sdk-dysmsapi.version>2.1.0</aliyun-java-sdk-dysmsapi.version>
<spring-javaformat-maven-plugin.version>0.0.15</spring-javaformat-maven-plugin.version> <jts.version>1.13</jts.version> <json-simple.version>1.1.1</json-simple.version> <json-lib.version>2.4</json-lib.version> <gt-geojson.version>19.0</gt-geojson.version>
<flink.version>1.12.0</flink.version> <scala.binary.version>2.12</scala.binary.version> <flink-connector-mysql-cdc.version>1.2.0</flink-connector-mysql-cdc.version> <gas-core.version>1.0.0-SNAPSHOT</gas-core.version> <aliyun-sdk-oss.version>3.10.2</aliyun-sdk-oss.version> <axis.version>1.4</axis.version> <xxl-job-core.version>2.3.0</xxl-job-core.version> <spring-boot-starter-super-scheduled.version>0.3.4</spring-boot-starter-super-scheduled.version> <spring-cloud-commons.version>2.1.1.RELEASE</spring-cloud-commons.version> <caffeine.version>2.7.0</caffeine.version> <spring-boot.version>2.3.2.RELEASE</spring-boot.version>
<itextpdf.version>5.5.10</itextpdf.version> <itext-asian.version>5.2.0</itext-asian.version> <flying-saucer-pdf.version>9.0.3</flying-saucer-pdf.version> <xmlworker.version>5.4.1</xmlworker.version> <eddsa.version>0.3.0</eddsa.version> <sshd-common.version>2.7.0</sshd-common.version> <sshd-core.version>2.7.0</sshd-core.version> <sshd-scp.version>2.7.0</sshd-scp.version> <geodesy.version>1.1.3</geodesy.version> </properties>
<distributionManagement> <repository> <id>nexus-releases</id> <name>Nexus Release Repository</name> <url>http://gas-dev.gaspim.cn:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://gas-dev.gaspim.cn:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
<dependencyManagement> <dependencies> <!-- spring-cloud支持 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> <!-- spring-cloud-alibaba支持 --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>${spring-cloud-alibaba.version}</version> <type>pom</type> <scope>import</scope> </dependency>
<!-- lombok支持 --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <scope>provided</scope> </dependency>
<!-- mysql支持 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <!-- mybatis支持 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <!-- mybatis-spring-boot-starter支持 --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-spring-boot-starter.version}</version> </dependency> <!-- mybatis-plus支持 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatisplus-spring-boot-starter.version}</version> </dependency> <!-- mybatis-plus-generator支持 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>${mybatis-plus-generator.version}</version> </dependency> <!-- mybatis-plus-core支持 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-core</artifactId> <version>${mybatis-plus-core.version}</version> </dependency> <!-- mybatis-plus-annotation支持 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-annotation</artifactId> <version>${mybatis-plus-annotation.version}</version> </dependency> <!-- mybatis-plus-extension支持 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-extension</artifactId> <version>${mybatis-plus-extension.version}</version> </dependency> <dependency> <groupId>p6spy</groupId> <artifactId>p6spy</artifactId> <version>${p6spy.version}</version> </dependency> <!-- dynamic-datasource-spring-boot-starter支持 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>dynamic-datasource-spring-boot-starter</artifactId> <version>${dynamic-datasource-spring-boot-starter.version}</version> </dependency> <!-- clickhouse支持 --> <dependency> <groupId>ru.yandex.clickhouse</groupId> <artifactId>clickhouse-jdbc</artifactId> <version>${clickhouse-jdbc.version}</version> </dependency> <!-- dm支持 --> <dependency> <groupId>com.dm</groupId> <artifactId>Dm7JdbcDriver</artifactId> <version>${dm.version}</version> </dependency>
<!-- magic-script支持 --> <dependency> <groupId>org.ssssssss</groupId> <artifactId>magic-script</artifactId> <version>${magic-script.version}</version> </dependency>
<!-- magic-api-spring-boot-starter支持 --> <dependency> <groupId>org.ssssssss</groupId> <artifactId>magic-api-spring-boot-starter</artifactId> <version>${magic-api-spring-boot-starter.version}</version> </dependency>
<!-- fastjson支持 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>${fastjson.version}</version> </dependency>
<!-- jackson支持 --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>${jackson-annotations.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson-databind.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> <version>${jackson-datatype-jsr310.version}</version> </dependency>
<!-- netty支持 --> <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>${netty.version}</version> </dependency>
<!-- netty-websocket-spring-boot-starter支持 --> <dependency> <groupId>org.yeauty</groupId> <artifactId>netty-websocket-spring-boot-starter</artifactId> <version>${netty-websocket-spring-boot-starter.version}</version> </dependency>
<!-- hutool支持 --> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>${hutool.version}</version> </dependency> <!-- zxing支持 --> <dependency> <groupId>com.google.zxing</groupId> <artifactId>core</artifactId> <version>${zxing.version}</version> </dependency> <!-- oshi-core支持 --> <dependency> <groupId>com.github.oshi</groupId> <artifactId>oshi-core</artifactId> <version>${oshi-core.version}</version> </dependency> <!-- guava支持 --> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> <!-- bitwalker支持 --> <dependency> <groupId>eu.bitwalker</groupId> <artifactId>UserAgentUtils</artifactId> <version>${bitwalker.version}</version> </dependency> <!-- commons-codec支持 --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>${commons-codec.version}</version> </dependency> <!-- commons-io支持 --> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>${commons-io.version}</version> </dependency> <!-- commons-net支持 --> <dependency> <groupId>commons-net</groupId> <artifactId>commons-net</artifactId> <version>${commons-net.version}</version> </dependency> <!-- snakeyaml支持 --> <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> <version>${snakeyaml.version}</version> </dependency> <!-- 汉字转拼音支持 --> <dependency> <groupId>com.belerweb</groupId> <artifactId>pinyin4j</artifactId> <version>${pinyin4j.version}</version> </dependency> <!-- easyexcel支持 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>${easyexcel.version}</version> </dependency>
<!-- tlog日志支持 --> <dependency> <groupId>com.yomahub</groupId> <artifactId>tlog-all-spring-boot-starter</artifactId> <version>${tlog.version}</version> </dependency>
<!-- sa-token支持 --> <dependency> <groupId>cn.dev33</groupId> <artifactId>sa-token-spring-boot-starter</artifactId> <version>${sa-token.version}</version> </dependency> <dependency> <groupId>cn.dev33</groupId> <artifactId>sa-token-spring-aop</artifactId> <version>${sa-token-spring-aop.version}</version> </dependency> <dependency> <groupId>cn.dev33</groupId> <artifactId>sa-token-dao-redis-jackson</artifactId> <version>${sa-token-dao-redis-jackson.version}</version> </dependency> <dependency> <groupId>cn.dev33</groupId> <artifactId>sa-token-alone-redis</artifactId> <version>${sa-token-alone-redis.version}</version> </dependency> <dependency> <groupId>cn.dev33</groupId> <artifactId>sa-token-core</artifactId> <version>${sa-token.version}</version> </dependency> <dependency> <groupId>com.github.penggle</groupId> <artifactId>kaptcha</artifactId> <version>${kaptcha.version}</version> </dependency>
<dependency> <groupId>com.vividsolutions</groupId> <artifactId>jts</artifactId> <version>${jts.version}</version> </dependency> <dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>${json-simple.version}</version> </dependency> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>${json-lib.version}</version> <classifier>jdk15</classifier> </dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-geojson 引用geo相关包--> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-geojson</artifactId> <version>${gt-geojson.version}</version> </dependency>
<!-- okhttp-feign相关支持 --> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>${okhttp3.version}</version> </dependency> <dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-okhttp</artifactId> <version>${feign-okhttp.version}</version> </dependency>
<!-- aio-core支持 --> <dependency> <groupId>org.smartboot.socket</groupId> <artifactId>aio-core</artifactId> <version>${aio-core.version}</version> </dependency>
<!-- swagger-annotations支持 --> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> <version>${swagger-annotations.version}</version> </dependency>
<dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-micro-spring-boot-starter</artifactId> <version>${knife4j.version}</version> </dependency> <!-- swagger增强支持(只需网关引入此支持) --> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>${knife4j.version}</version> </dependency> <!-- knife4j-ui增强支持(只需网关引入此支持) --> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-ui</artifactId> <version>${knife4j.version}</version> </dependency> <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-annotations</artifactId> <version>${knife4j.version}</version> </dependency> <!-- aliyun-java-sdk 支持 --> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-core</artifactId> <version>${aliyun-java-sdk-core.version}</version> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-dysmsapi</artifactId> <version>${aliyun-java-sdk-dysmsapi.version}</version> </dependency> <!-- aliyun-oss 支持 --> <dependency> <groupId>com.aliyun.oss</groupId> <artifactId>aliyun-sdk-oss</artifactId> <version>${aliyun-sdk-oss.version}</version> </dependency> <!-- base64 支持 --> <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis</artifactId> <version>${axis.version}</version> </dependency> <!-- xxl-job-core 支持 --> <dependency> <groupId>com.xuxueli</groupId> <artifactId>xxl-job-core</artifactId> <version>${xxl-job-core.version}</version> </dependency> <dependency> <groupId>com.github.guoyixing</groupId> <artifactId>spring-boot-starter-super-scheduled</artifactId> <version>${spring-boot-starter-super-scheduled.version}</version> </dependency> <!-- flink支持 --> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-streaming-java_${scala.binary.version}</artifactId> <version>${flink.version}</version> </dependency> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-clients_${scala.binary.version}</artifactId> <version>${flink.version}</version> </dependency> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-runtime-web_${scala.binary.version}</artifactId> <version>${flink.version}</version> </dependency> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-connector-kafka_${scala.binary.version}</artifactId> <version>${flink.version}</version> </dependency> <dependency> <groupId>com.alibaba.ververica</groupId> <artifactId>flink-connector-mysql-cdc</artifactId> <version>${flink-connector-mysql-cdc.version}</version> </dependency> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId> <version>${flink.version}</version> </dependency> <!-- spring-cloud-commons 支持 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-commons</artifactId> <version>${spring-cloud-commons.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> <version>${spring-boot.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <version>${spring-boot.version}</version> </dependency> <dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> <version>${caffeine.version}</version> </dependency> <dependency> <groupId>net.i2p.crypto</groupId> <artifactId>eddsa</artifactId> <version>${eddsa.version}</version> </dependency> <dependency> <groupId>org.apache.sshd</groupId> <artifactId>sshd-common</artifactId> <version>${sshd-common.version}</version> </dependency> <dependency> <groupId>org.apache.sshd</groupId> <artifactId>sshd-core</artifactId> <version>${sshd-core.version}</version> </dependency> <dependency> <groupId>org.apache.sshd</groupId> <artifactId>sshd-scp</artifactId> <version>${sshd-scp.version}</version> </dependency> <dependency> <groupId>org.gavaghan</groupId> <artifactId>geodesy</artifactId> <version>${geodesy.version}</version> </dependency> </dependencies> </dependencyManagement>
<build> <plugins> <plugin> <groupId>io.spring.javaformat</groupId> <artifactId>spring-javaformat-maven-plugin</artifactId> <version>${spring-javaformat-maven-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <encoding>UTF-8</encoding> <showWarnings>true</showWarnings> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.2.0</version> <configuration> <archive> <addMavenDescriptor>false</addMavenDescriptor> </archive> </configuration> <executions> <execution> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> <addClasspath>true</addClasspath> </manifest> </archive> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.2.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.1.2</version> </plugin> <plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <version>1.3.6</version> <configuration> <repository>${project.artifactId}</repository> <buildArgs> <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> </buildArgs> </configuration> </plugin> </plugins> <resources> <resource> <directory>src/main/java</directory> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> </build>

<repositories> <!--Geotool官方的仓库 下载geotools 手动添加maven--> <repository> <id>osgeo</id> <name>OSGeo Release Repository</name> <url>https://repo.osgeo.org/repository/release/</url> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> <repository> <id>osgeo-snapshot</id> <name>OSGeo Snapshot Repository</name> <url>https://repo.osgeo.org/repository/snapshot/</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>false</enabled> </releases> </repository>
<repository> <id>aliyun-repos</id> <name>Aliyun Repository</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>sonatype-repos</id> <name>Sonatype Repository</name> <url>https://oss.sonatype.org/content/groups/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>sonatype-repos-s</id> <name>Sonatype Repository</name> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring-snapshots</id> <name>Spring Snapshots</name> <url>https://repo.spring.io/snapshot</url> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>
<pluginRepositories> <pluginRepository> <id>aliyun-repos</id> <name>Aliyun Repository</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories></project>
复制代码

这两个 pom 文件是我直接从项目里粘过来的,Easy Code 显然不用这么多依赖。

吐槽:我见过有些人,都不带上网查的,直接手敲 pom 文件,那可能就是高手的常规操作,也许将来我也直接手敲。

4. Template 模板


Easy Code:Easy Code (shujuhaiyang.com)


上传了一个模板,是洋哥写好的,在下边又贴了一份。(针对达梦数据库的模板)

  1. controller


##导入宏定义$!{define.vm}$!{init.vm}##设置表后缀(宏定义)#setTableSuffix("Controller")
##保存文件(宏定义)#save("/controller", "Controller.java")
##包路径(宏定义)#setPackageSuffix("controller")
##定义服务名#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), "Service"))#set($lowerCase = $!tool.firstLowerCase($!tableInfo.name))
import cn.dev33.satoken.annotation.SaCheckPermission;import com.baomidou.mybatisplus.core.toolkit.Wrappers;import com.gas.vo.PageVO;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.dto.$!{tableInfo.name}DTO;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.dto.$!{tableInfo.name}PageDTO;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.po.$!{tableInfo.name};import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.service.$!{tableInfo.name}Service;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.vo.$!{tableInfo.name}PageVO;import com.gas.response.R;import com.gas.utils.bean.GasBeanUtil;import com.gas.valid.group.Update;import io.swagger.annotations.Api;import io.swagger.annotations.ApiImplicitParam;import io.swagger.annotations.ApiOperation;import lombok.extern.slf4j.Slf4j;import org.springframework.validation.annotation.Validated;import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;import javax.validation.constraints.NotBlank;import java.util.Arrays;
##表注释(宏定义)#tableComment(" Controller")@Api(tags = {"$!{tableInfo.comment}"})@Slf4j@Validated@RestController@RequestMapping("$!{lowerCase}")public class $!{tableName}{ @Resource private $!{tableInfo.name}Service $!{serviceName}; @ApiOperation(value = "新增") @PostMapping("/save") public R save(@RequestBody @Validated $!{tableInfo.name}DTO dto) { $!{tableInfo.name} model = GasBeanUtil.copyProperties(dto, $!{tableInfo.name}.class); boolean res = $!{serviceName}.save(model); return res ? R.success("保存成功") : R.miss("保存失败"); }
@ApiOperation(value = "修改") @PostMapping("/update") public R updateById(@RequestBody @Validated(value = Update.class) $!{tableInfo.name}DTO dto) { $!{tableInfo.name} model = GasBeanUtil.copyProperties(dto, $!{tableInfo.name}.class); boolean res = $!{serviceName}.updateById(model); return res ? R.success("修改成功") : R.miss("修改失败"); }
@ApiOperation(value = "查询单条") @GetMapping("/findById") @ApiImplicitParam(name = "id", dataTypeClass = String.class, value = "id", example = "1", required = true) public R<$!{tableInfo.name}> findById(@NotBlank(message = "id不能为空") String id) { $!{tableInfo.name} model = $!{serviceName}.getById(id); return R.ok(model); }
@ApiOperation(value = "删除") @GetMapping("/delete") @ApiImplicitParam(name = "ids", dataTypeClass = String.class, value = "ids串", example = "1,2,3", required = true) public R deleteById(@NotBlank(message = "ids不能为空") String ids) { boolean res = $!{serviceName}.removeByIds(Arrays.asList(ids.split(","))); return res ? R.success("删除成功") : R.miss("删除失败"); } @ApiOperation(value = "分页查询",notes="$!{lowerCase}-page") @GetMapping("/page") @SaCheckPermission("$!{lowerCase}-page") public R<PageVO<$!{tableInfo.name}PageVO>> page(@Validated $!{tableInfo.name}PageDTO dto) { PageVO<$!{tableInfo.name}PageVO> page = $!{serviceName}.findPage(dto); return R.ok(page); }}
复制代码
  1. xml


##引入mybatis支持$!{mybatisSupport.vm}##导入宏定义$!{define.vm}$!{init.vm}##设置保存名称与保存位置$!callback.setFileName($tool.append($!{tableInfo.name}, "Mapper.xml"))$!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper/$!{tool.firstLowerCase($!tableInfo.name)}"))##拿到主键#if(!$tableInfo.pkColumn.isEmpty())    #set($pk = $tableInfo.pkColumn.get(0))#end
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="$!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.mapper.$!{tableInfo.name}Mapper"> <select id="findPage" resultType="$!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.vo.$!{tableInfo.name}PageVO"> SELECT ID, #foreach($column in $tableInfo.fullColumn) $!{column.obj.name}, #end CREATE_TIME, GENERAL_STATUS FROM $!tableInfo.obj.name <where>#foreach($column in $tableInfo.fullColumn) <if test="model.$!column.name != null#if($column.type.equals("java.lang.String")) and model.$!column.name != ''#end"> AND $!column.obj.name = #{model.$!column.name} </if>#end </where> ORDER BY ID DESC </select></mapper>
复制代码
  1. impl


##导入宏定义$!{define.vm}$!{init.vm}##设置表后缀(宏定义)#setTableSuffix("ServiceImpl")
##保存文件(宏定义)#save("/service/impl", "ServiceImpl.java")
##包路径(宏定义)#setPackageSuffix("service.impl")
import com.gas.vo.PageVO;import com.baomidou.mybatisplus.extension.plugins.pagination.Page;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.mapper.$!{tableInfo.name}Mapper;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.po.$!{tableInfo.name};import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.service.$!{tableInfo.name}Service;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.dto.$!{tableInfo.name}PageDTO;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.vo.$!{tableInfo.name}PageVO;import org.springframework.stereotype.Service;
import java.util.Optional;
##表注释(宏定义)#tableComment(" Impl")@Servicepublic class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Mapper, $!{tableInfo.name}> implements $!{tableInfo.name}Service { @Override public PageVO<$!{tableInfo.name}PageVO> findPage($!{tableInfo.name}PageDTO dto) { Page<$!{tableInfo.name}PageVO> page = baseMapper.findPage(new Page(dto.getCurrent(),dto.getSize()),dto); return new PageVO(page.getRecords(),page.getTotal()); }}
复制代码
  1. service


##导入宏定义$!{define.vm}$!{init.vm}##设置表后缀(宏定义)#setTableSuffix("Service")
##保存文件(宏定义)#save("/service", "Service.java")
##包路径(宏定义)#setPackageSuffix("service")
import com.gas.vo.PageVO;import com.baomidou.mybatisplus.extension.service.IService;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.dto.$!{tableInfo.name}PageDTO;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.po.$!{tableInfo.name};import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.vo.$!{tableInfo.name}PageVO;
##表注释(宏定义)#tableComment(" Service")public interface $!{tableName} extends IService<$!{tableInfo.name}> { /** * 分页查询 * @param dto * @return */ PageVO<$!{tableInfo.name}PageVO> findPage($!{tableInfo.name}PageDTO dto);}
复制代码
  1. mapper


##导入宏定义$!{define.vm}$!{init.vm}##设置表后缀(宏定义)#setTableSuffix("Mapper")
##保存文件(宏定义)#save("/mapper", "Mapper.java")
##包路径(宏定义)#setPackageSuffix("mapper")
import com.baomidou.mybatisplus.core.mapper.BaseMapper;import com.baomidou.mybatisplus.extension.plugins.pagination.Page;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.dto.$!{tableInfo.name}PageDTO;import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.po.$!{tableInfo.name};import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.vo.$!{tableInfo.name}PageVO;import org.apache.ibatis.annotations.Param;##表注释(宏定义)#tableComment(" Mapper")public interface $!{tableName} extends BaseMapper<$!{tableInfo.name}> {
Page<$!{tableInfo.name}PageVO> findPage(Page page, @Param("model") $!{tableInfo.name}PageDTO dto);}
复制代码


  1. po


##引入宏定义$!{define.vm}$!{init.vm}##使用宏定义设置回调(保存位置与文件后缀)#save("/po", ".java")
##使用宏定义设置包后缀#setPackageSuffix("po")
##使用全局变量实现默认包导入$!{autoImport.vm}import com.baomidou.mybatisplus.annotation.TableField;import com.baomidou.mybatisplus.annotation.TableName;import com.gas.base.entity.BaseEntity;import io.swagger.annotations.ApiModelProperty;import lombok.Data;import lombok.experimental.Accessors;
import java.io.Serializable;##使用宏定义实现类注释信息#tableComment(" PO")@Accessors(chain = true)@Data@TableName("$!{tableInfo.obj.name}")public class $!{tableInfo.name} extends BaseEntity{#foreach($column in $tableInfo.fullColumn)
@TableField(value = "$!{column.obj.name}") @ApiModelProperty(value = "${column.comment}") private $!{tool.getClsNameByFullName($column.type)} $!{column.name};#end
#foreach($column in $tableInfo.pkColumn) #break#end}
复制代码


  1. vo


##引入宏定义$!{define.vm}$!{init.vm}##使用宏定义设置回调(保存位置与文件后缀)#save("/vo", "PageVO.java")
##使用宏定义设置包后缀#setPackageSuffix("vo")
##使用全局变量实现默认包导入$!{autoImport.vm}

import $!{tableInfo.savePackageName}.$!{tool.firstLowerCase($!tableInfo.name)}.po.$!{tableInfo.name};import lombok.Data;
##使用宏定义实现类注释信息#tableComment(" 分页VO")@Datapublic class $!{tableInfo.name}PageVO extends $!{tableInfo.name}{}
复制代码


  1. dto


##引入宏定义$!{define.vm}$!{init.vm}##使用宏定义设置回调(保存位置与文件后缀)#save("/dto", "DTO.java")
##使用宏定义设置包后缀#setPackageSuffix("dto")
##使用全局变量实现默认包导入$!{autoImport.vm}
import com.gas.valid.group.Update;import io.swagger.annotations.ApiModelProperty;import lombok.Data;
import javax.validation.constraints.NotNull;##使用宏定义实现类注释信息#tableComment(" DTO")@Datapublic class $!{tableInfo.name}DTO { @ApiModelProperty(value = "id", required = true) @NotNull(message = "id,值不能为空", groups = Update.class) private Long id;#foreach($column in $tableInfo.fullColumn)
@ApiModelProperty(value = "${column.comment}") private $!{tool.getClsNameByFullName($column.type)} $!{column.name};#end
}
复制代码


  1. pageDto


##引入宏定义$!{define.vm}$!{init.vm}##使用宏定义设置回调(保存位置与文件后缀)#save("/dto", "PageDTO.java")
##使用宏定义设置包后缀#setPackageSuffix("dto")
##使用全局变量实现默认包导入$!{autoImport.vm}
import com.gas.base.dto.BasePageDTO;import io.swagger.annotations.ApiModelProperty;import lombok.Data;
##使用宏定义实现类注释信息#tableComment(" DTO")@Datapublic class $!{tableInfo.name}PageDTO extends BasePageDTO{#foreach($column in $tableInfo.fullColumn)
@ApiModelProperty(value = "${column.comment}") private $!{tool.getClsNameByFullName($column.type)} $!{column.name};#end
}
复制代码
5. Global Config 全局配置

1 autoImport.vm 自动导入


##自动导入包(仅导入实体属性需要的包,通常用于实体类)#foreach($import in $importList)import $!import;#end
复制代码

2 define 宏定义


##(Velocity宏定义)
##定义设置表名后缀的宏定义,调用方式:#setTableSuffix("Test")#macro(setTableSuffix $suffix) #set($tableName = $!tool.append($tableInfo.name, $suffix))#end
##定义设置包名后缀的宏定义,调用方式:#setPackageSuffix("Test")#macro(setPackageSuffix $suffix)#if($suffix!="")package #end#if($tableInfo.savePackageName!="")$!{tableInfo.savePackageName}.$!tool.firstLowerCase($!tableInfo.name).#{end}$!suffix;#end
##定义直接保存路径与文件名简化的宏定义,调用方式:#save("/entity", ".java")#macro(save $path $fileName) $!callback.setSavePath($tool.append(${tableInfo.savePath},"/",$!tool.firstLowerCase($!tableInfo.name),$path)) $!callback.setFileName($tool.append(${tableInfo.name}, $fileName))#end
##定义表注释的宏定义,调用方式:#tableComment("注释信息")#macro(tableComment $desc)/** * $!{tableInfo.comment}($!{tableInfo.name})$desc * * @author $!author */#end
##定义GET,SET方法的宏定义,调用方式:#getSetMethod($column)#macro(getSetMethod $column)
public $!{tool.getClsNameByFullName($column.type)} get$!{tool.firstUpperCase($column.name)}() { return $!{column.name}; }
public void set$!{tool.firstUpperCase($column.name)}($!{tool.getClsNameByFullName($column.type)} $!{column.name}) { this.$!{column.name} = $!{column.name}; }#end
复制代码

3 init 初始化时去掉表前缀


###set($name =  $tableInfo.obj.name.replaceFirst("tb_meter_",""))#set($name =  $name.replaceFirst("tb_user_",""))#set($name =  $name.replaceFirst("tb_warehouse_",""))#set($name =  $name.replaceFirst("tb_address_",""))#set($name =  $name.replaceFirst("TB_BASIC_",""))#set($name =  $name.replaceFirst("tb_",""))#set($name =  $name.replaceFirst("TB_",""))#set($name =  $name.replaceFirst("GAS_",""))#set($name =  $name.replaceFirst("_STATISTICS",""))#set($name =  $name.replaceFirst("YEAR_",""))#set($name =  $name.replaceFirst("STA_ENSURE_",""))##去掉表的t_前缀$!tableInfo.setName($tool.getClassName($name.replaceFirst("basic_","")))
##参考阿里巴巴开发手册,POJO 类中布尔类型的变量,都不要加 is 前缀,否则部分框架解析会引起序列化错误#foreach($column in $tableInfo.fullColumn)#if($column.name.startsWith("is") && $column.type.equals("java.lang.Boolean")) $!column.setName($tool.firstLowerCase($column.name.substring(2)))#end#end
##实现动态排除列#set($temp = $tool.newHashSet("id","createBy","createTime","updateBy","updateTime","generalStatus"))#foreach($item in $temp) #set($newList = $tool.newArrayList()) #foreach($column in $tableInfo.fullColumn) #if($column.name!=$item) ##带有反回值的方法调用时使用$tool.call来消除返回值 $tool.call($newList.add($column)) #end #end ##重新保存 $tableInfo.setFullColumn($newList)#end
##对importList进行篡改#set($temp = $tool.newHashSet())#foreach($column in $tableInfo.fullColumn) #if(!$column.type.startsWith("java.lang.")) ##带有反回值的方法调用时使用$tool.call来消除返回值 $tool.call($temp.add($column.type)) #end#end##覆盖#set($importList = $temp)
复制代码

4 mybatisSupport.vm 对 Mybatis 进行支持


##针对Mybatis 进行支持,主要用于生成xml文件#foreach($column in $tableInfo.fullColumn)    ##储存列类型    $tool.call($column.ext.put("sqlType", $tool.getField($column.obj.dataType, "typeName")))    #if($tool.newHashSet("java.lang.String").contains($column.type))        #set($jdbcType="VARCHAR")    #elseif($tool.newHashSet("java.lang.Boolean", "boolean").contains($column.type))        #set($jdbcType="BOOLEAN")    #elseif($tool.newHashSet("java.lang.Byte", "byte").contains($column.type))        #set($jdbcType="BYTE")    #elseif($tool.newHashSet("java.lang.Integer", "int", "java.lang.Short", "short").contains($column.type))        #set($jdbcType="INTEGER")    #elseif($tool.newHashSet("java.lang.Long", "long").contains($column.type))        #set($jdbcType="INTEGER")    #elseif($tool.newHashSet("java.lang.Float", "float", "java.lang.Double", "double").contains($column.type))        #set($jdbcType="NUMERIC")    #elseif($tool.newHashSet("java.util.Date", "java.sql.Timestamp", "java.time.Instant", "java.time.LocalDateTime", "java.time.OffsetDateTime", "	java.time.ZonedDateTime").contains($column.type))        #set($jdbcType="TIMESTAMP")    #elseif($tool.newHashSet("java.sql.Date", "java.time.LocalDate").contains($column.type))        #set($jdbcType="TIMESTAMP")    #else        ##其他类型        #set($jdbcType="VARCHAR")    #end    $tool.call($column.ext.put("jdbcType", $jdbcType))#end
##定义宏,查询所有列#macro(allSqlColumn)#foreach($column in $tableInfo.fullColumn)$column.obj.name#if($velocityHasNext), #end#end#end
复制代码

在 common 里有一个公用的,被 po 继承的类

package com.gas.base.entity;
import com.baomidou.mybatisplus.annotation.*;import com.fasterxml.jackson.annotation.JsonFormat;import com.fasterxml.jackson.databind.annotation.JsonDeserialize;import com.fasterxml.jackson.databind.annotation.JsonSerialize;import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;import io.swagger.annotations.ApiModelProperty;import lombok.Data;
import java.io.Serializable;import java.time.LocalDateTime;
/** * @Author zhaoyang * @create 2022/2/9 9:58 */@Datapublic class BaseEntity implements Serializable {
private static final long serialVersionUID = -7812638232667596208L; @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty("主键") @TableId(value = "ID",type = IdType.AUTO) private Long id;
@ApiModelProperty("启用状态 0:禁用 1:启用") @TableField(value = "GENERAL_STATUS", fill = FieldFill.INSERT) private Integer generalStatus;
@ApiModelProperty("创建人") @TableField(value = "CREATE_BY", fill = FieldFill.INSERT) private String createBy;
@ApiModelProperty("创建时间") @JsonDeserialize(using = LocalDateTimeDeserializer.class) @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField(value = "CREATE_TIME", fill = FieldFill.INSERT) private LocalDateTime createTime;
@ApiModelProperty("修改人") @TableField(value = "UPDATE_BY", fill = FieldFill.UPDATE) private String updateBy;
@ApiModelProperty("修改时间") @JsonDeserialize(using = LocalDateTimeDeserializer.class) @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField(value = "UPDATE_TIME", fill = FieldFill.UPDATE, update = "NOW()") private LocalDateTime updateTime;}
复制代码
6. Generate Code 生成代码

生成代码就简单了

右键选中表 —> EasyCode —>Generate Code


发布于: 1 小时前阅读数: 11
用户头像

孙永潮

关注

走好自己选择的路,而不是选择好走的路。 2022.06.13 加入

想要得到什么(工作、薪水、地位、声望、爱情……),最好的办法就是让自己配得上。

评论

发布
暂无评论
Java Idea插件Easy Code_idea插件_孙永潮_InfoQ写作社区