IDEA文件模板

最近观看一些项目实战时,发现一些文件需要自己创建,而且文件大多重复,想到了IDEA中具有制作文件模板的作用,写了几个,方便开发的时候使用,可以大大简化代码创作环境。
文件模板路径 File–> Setting --> Editor–>File and Code Templates Files

  1. Bean 实体类

使用@Data注解的时候需要下载lombok插件,并在pom.xml文件导入相关依赖。

① File-Setting-Plugins-Installed安装lombok插件在这里插入图片描述
② 导入相关依赖

 <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.18</version>
            <scope>provided</scope>
        </dependency>

在这里插入图片描述

③ 文件模板

import lombok.Data;
@Data

public class  ${NAME} {
}

在这里插入图片描述
2. SpringBoot启动项SpringBootApplication

使用@SpringBootApplication注解的时候需要pom.xml文件导入相关依赖。

 import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

public class ${NAME} {
    public static void main(String[] args) {
        SpringApplication.run(${NAME}.class,args);
    }
}

在这里插入图片描述

  1. Mapper.xml

使用@Data注解的时候需要下载lombok插件,并在pom.xml文件导入相关依赖。

<?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="">
    <select id=" " resultType="   ">
        select * from  
    </select>
    <insert id=" " parameterType=" ">
        insert into   ( )
            values(#{ },#{ })
    </insert>
    <delete id=" " parameterType=" ">
        delete from smbms_provider where id=#{delId}
    </delete>
   
    <update id=" " parameterType=" ">
        update  
            set  =#{ }, =#{ },proContact=#{proContact},proPhone=#{proPhone},proAddress=#{proAddress},proFax=#{proFax},modifyBy=#{modifyBy},modifyDate=#{modifyDate}
                where id = #{id}
    </update>
    
</mapper>

在这里插入图片描述

  1. application.yml配置文件

```java
服务端口号:
server:
  port: 8081

Spring配置:

spring:
  datasource: #配置数据源四要素
    url: jdbc:mysql://localhost:3306/travel_heima
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
  application: #服务名称
    name: consumer-service

MyBatis配置:
mybatis:
  type-aliases-package: cn.xxx.pojo
  configuration:
    map-underscore-to-camel-case: true #开启驼峰匹配

Eureka服务配置:
eureka:
  client:
    fetch-registry: false #拉取服务
    register-with-eureka: false #注册自己
    service-url:
      defaultZone: http://127.0.0.1:10086/eureka,http://127.0.0.1:10087/eureka #集群互相注册
  instance:
    ip-address: 127.0.0.1
    instance-id: ${eureka.instance.ip-address}:${server.port}

zuul网关配置:
zuul:
  prefix: /api #前缀
  routes:
    user-service:
     path: /user/** #访问路径
     serviceId: user-service #服务id
     strip-prefix: false #是否开启前缀
  ignored-services:
    - user-service
    - consumer-feign

Ribbon负载均衡配置:
ConnectTimeout: 500 # ribbon链接超时时长
	  ReadTimeout: 2000 # ribbon读取超时时长
	  MaxAutoRetries: 0  # 当前服务重试次数
	  MaxAutoRetriesNextServer: 1 # 切换服务重试次数
	  OkToRetryOnAllOperations: false # 是否对所有的请求方式都重试,只对get请求重试

Hystrix配置:
hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 5000 # 熔断超时时长:6000ms




spring:
# profiles:
#   active: dev
 datasource:
   driver-class-name: com.mysql.cj.jdbc.Driver
   url: jdbc:mysql://127.0.0.1:3306/smbms?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT
   username: root
   password: root
server:
  port: 8080
mybatis:
  config-location: classpath:mybatis-config.xml
    

在这里插入图片描述

文件模板创建好后,在新建文件中可以看到已经创建的文件模板,下次创建可以直接使用模板,只要改改部分代码即可使用,方便开发。在这里插入图片描述
在这里插入图片描述
最近只准备了这几个文件模板,如果有其它的文件模板可以参考以上流程新建即可。第一次发表文章,不熟悉怎么写,若有问题欢迎提出,马上改正,若其中有疏漏,也可参考 IDEA之常用模板设置 ,最后欢迎大家在评论区讨论分享更多的文件模板。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值