代码拉取完成,页面将自动刷新
同步操作将从 devil13th/com-thd-springboot-framework-parent 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
[TOC]
添加依赖
在项目web模块
中添加框架中的框架web模块
依赖
<dependency>
<groupId>com.thd.springboot.framework</groupId>
<artifactId>com-thd-springboot-framework-web</artifactId>
<version>1.0.0-SNAPSHOT</version>
在项目starter模块
的application.yml中配置端口和项目根
server:
port: 8899
servlet:
context-path: /thd
添加Controller
@Controller
@RequestMapping("/...")
public class ExampleController extends BasicController {
@ResponseBody
@RequestMapping("/test")
// url : http://127.0.0.1:8899/thd/example/test
public Message testLog(){
this.getLogger().info("test()");
this.getLogger().debug("debug");
this.getLogger().error("error");
this.getLogger().warn("warn");
return Message.success();
}
}
项目starter模块
的启动类加注释进行扫描配置
@SpringBootApplication(scanBasePackages = "com.thd")
public class ApplicationServer{
...
}
项目starter模块
的application.yml中添加数据源和mybatis的配置
spring:
############################ Db ############################
datasource:
# 数据库的url、登录名、密码和数据库名
url: jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull
username: root
password: 123456
# 使用阿里的Druid连接池
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# druid:
# 连接池的配置信息
# 初始化大小,最小,最大
initialSize: 5
minIdle: 5
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
# 打开PSCache,并且指定每个连接上PSCache的大小
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
filters: stat,wall
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录 单位毫秒
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=50
# 配置监控服务器
stat-view-servlet:
login-username: admin
login-password: 123456
reset-enable: false
url-pattern: /druid/*
# 添加IP白名单
#allow:
# 添加IP黑名单,当白名单和黑名单重复时,黑名单优先级更高
#deny:
web-stat-filter:
# 添加过滤规则
url-pattern: /*
# 忽略过滤格式
exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
############################ Db - mybatis ############################
mybatis:
mapper-locations: classpath:com/thd/springboot/framework/example/mapper/*.xml #这里是mapper的配置文件
# 这里是实体类的包 添加这个配置后就不用在mapper.xml配置文件中aliases了
type-aliases-package: com.thd.springboot.framework.example.entity
configuration:
map-underscore-to-camel-case: true # 驼峰属性与数据库字段下划线自动转换
日志框架使用Logback,也是Springboot 默认的日志框架,从依赖中可以看出
spring-boot-dependencies
|- spring-boot-starter
|- spring-boot-starter-logging
|- logback-classic
|- log4j-to-slf4j
|- jul-to-slf4j
所以只要使用Springboot框架,Logback的依赖自动加到了项目中
以下内容均在项目starter模块
中
applicatoin.yml 中配置logback-spring.xml的位置和日志保存的位置
logging:
config: classpath:config/logback-spring.xml
path: D:/deleteme/logbacks
添加logback-spring.xml
将logback-spring.xml放到resources/config目录下
logback-spring.xml内容
参见com-thd-springboot-framework-example-starter项目下的logback-spring.xml
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。