目录
实体类
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#parse("Controller Header.java")
@RestController
@RequestMapping("/${NAME}")
public class ${NAME}Controller {
}
Mapper
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
#parse("Mapper Header.java")
@Mapper
public interface ${NAME}Mapper extends BaseMapper<${NAME}> {
}
Mapper.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="">
<!-- 实体类 -->
<resultMap type="${NAME}" id="${NAME}Result">
</resultMap>
<!-- sql语句 -->
<sql id="select${NAME}List">
</sql>
<!-- 方法 -->
<select id="query${NAME}List" parameterType="${NAME}" resultMap="${NAME}Result">
<include refid="select${NAME}List"/>
<where>
<if test="fieldName != null and fieldName != ''"> and tableFieldName like concat('%', #{fieldName}, '%')</if>
<if test="startDate != null and startDate != ''">and tableFieldName >= #{startDate}</if>
<if test="endDate != null and endDate != ''">and tableFieldName <= #{endDate}</if>
</where>
</select>
</mapper>
Service
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("Service Header.java")
public interface ${NAME}Service {
}
ServiceImpl
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
#parse("ServiceImpl Header.java")
@Service
public class ${NAME}ServiceImpl extends ServiceImpl<${NAME}Mapper, ${NAME}> implements ${NAME}Service {
}
Controller
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#parse("Controller Header.java")
@RestController
@RequestMapping("/${NAME}")
public class ${NAME}Controller {
}
application.yml
server:
port: 8081
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数,默认为100
accept-count: 1000
threads:
# tomcat最大线程数,默认为200
max: 800
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
spring:
profiles: # 指定配置文件 只有一个配置文件就去掉这个配置
active: dev
datasource: # 数据源
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# driver-class-name: net.sourceforge.jtds.jdbc.Driver
druid:
master: # 主数据源
url: jdbc:sqlserver://localhost:1433;DatabaseName=dataBase
username: root
password: root
slave: # 从库数据源
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
ekp:
enabled: true
url: jdbc:sqlserver://localhost:1433;SelectMethod=cursor;DatabaseName=dataBase
username: root
password: root
hikari:
connection-test-query: SELECT 1 #测试连接是否可用
# redis 配置
redis:
# 地址
host: localhost
# 端口,默认为6379
port: 6379
# 数据库索引
database: 10
# 密码
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
banner:
location: banner.txt # banner样式
servlet: # 文件上传
multipart:
max-file-size: 10MB # 单个文件大小,默认为10MB
max-request-size: 50MB # 总上传文件大小,默认为50MB
mvc:
async:
request-timeout: 60000
messages: # 资源信息
basename: i18n/messages # 国际化资源文件路径
# 服务模块
devtools:
restart:
# 热部署开关
enabled: true
mybatis-plus:
mapper-locations: classpath:mapper/**/*Mapper.xml # xml文件路径扫描
typeAliasesPackage: com.**.**.entity # 实体类包路径扫描
global-config:
db-config:
id-type: AUTO
logic-delete-value: -1
logic-not-delete-value: 0
banner: false
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
mapUnderscoreToCamelCase: true
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# PageHelper分页插件
pagehelper:
helperDialect: sqlserver
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /dev-api
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认30分钟)
expireTime: 30
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间(默认10分钟)
lockTime: 10
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# 日志配置
logging:
level:
com.akesobio: debug
org.springframework: warn
application.yml 精简
server:
port: 9093
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数,默认为100
accept-count: 1000
threads:
# tomcat最大线程数,默认为200
max: 800
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
spring:
# 切换配置文件
profiles:
active: prod
# banner样式
banner:
location: banner.txt
# 文件上传
servlet:
multipart:
max-file-size: 10MB # 单个文件上传大小,默认为10MB
max-request-size: 50MB # 总上传文件大小,默认为50MB
mvc:
async:
request-timeout: 60000
mybatis-plus:
mapper-locations: classpath:mapper/**/*Mapper.xml
typeAliasesPackage: com.leslie.**.entity
global-config:
db-config:
id-type: auto
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
mapUnderscoreToCamelCase: true
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 注释后 SQL 查询数据,控制台不打印结果
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# 日志配置
logging:
level:
com.leslie: debug
org.springframework: warn
application-prod.yml
spring:
datasource: # 数据源 单数据源时,url、username、password 挪到第一个 datasource 下
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# hikari:
# connection-test-query: SELECT 1 #测试连接是否可用
dynamic:
primary: master
strict: false
datasource:
master:
url: jdbc:sqlserver://ip:1433;DatabaseName=
username:
password:
department:
# enabled: true
url: jdbc:sqlserver://ip:1433;SelectMethod=cursor;DatabaseName=
username:
password:
# 初始连接数
druid:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 900000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 900000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
Idea 配置方法
使用方法
在需要新建的文件夹路径,右键选择新建
上图中此内容为头部注释配置
#parse("Controller Header.java")