
SpringBoot
小龙舟~
这个作者很懒,什么都没留下…
展开
-
logback 指定异常堆栈信息的输出行数
使用logback作为日志输出框架实现。当程序出现异常时,输出的堆栈信息一般很多,但对于排查问题时是有点多余的,一般都是第三方包内部的各种调用信息,而对我们有用的信息往往就在上面几行此时可以选择简化堆栈信息的打印,指定堆栈信息输出行数在pattern标签中添加如下信息即可%ex{5}示例%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{traceId}] [%p] [%c{0}:%L] %m %n %ex{5}参考文档...原创 2020-11-24 17:25:10 · 3530 阅读 · 0 评论 -
Flyway初体验
使用pom.xml<!-- spring boot中不需要指定版本--><dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-core</artifactId></dependency>resources目录下新建 db/migration 这个目录在上诉目录中添加.sql文件,启动项目即可命名规则V202011.010原创 2020-11-10 17:20:25 · 180 阅读 · 0 评论 -
Java 代码生成器(CURD CRUD)
Java 代码生成器 CURD CRUD原创 2020-11-09 15:29:14 · 2913 阅读 · 4 评论 -
logback.xml if 条件判断
本地开发需要打印控制台日志,而测试以及生产环境则不需要,此时可在logback.xml中通过配置文件值进行条件判断。1.先上代码logback.xml<?xml version="1.0" encoding="UTF-8"?><configuration scan="true" scanPeriod="30 seconds"> <springProperty scope="context" name="env" source="deploy.env"/>.原创 2020-11-05 14:07:11 · 8408 阅读 · 2 评论 -
java.io.FileNotFoundException - 使用ResourceUtils.getFile(“xxxx“) 加载配置文件报错
Caused by: java.io.FileNotFoundException: class path resource [xxxx.json] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/x/xx/xxx.jar!/BOOT-INF/classes!/xxxx.jsonCaused by: java.io.FileNotFoundException:原创 2020-10-29 10:58:02 · 1065 阅读 · 0 评论 -
spring boot 加载配置文件 properties / json
demo.properties配置文件main |_ java |_ resources |_ property |_ demo.propertiesdemo.desc=spring boot property config of properties filedemo.babbys[0].name=Tomdemo.babbys[0].age=2demo.babbys[0].address=苏州demo.babbys[1].name=Lilydemo.babbys[1].ag原创 2020-10-27 09:59:31 · 2942 阅读 · 0 评论 -
spring boot使用linux的service启动方式
1.maven pom添加spring-boot-maven-plugin <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId>原创 2020-10-26 14:40:00 · 1077 阅读 · 3 评论 -
SpringBoot支持跨域 CORS
自定义CorsFilter Bean@Configurationpublic class CorsConfig { @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = getCorsConfigurationSource(); return new CorsFilter(source); } public UrlBasedCor原创 2020-10-21 16:31:54 · 131 阅读 · 0 评论 -
Bean初始化、销毁执行方法
初始化@PostConstruct 注解implements InitializingBean, @Override afterPropertiesSet()销毁@PreDestroy 注解implements DisposableBean, @Override destroy()@Component@Slf4jpublic class Demo implements InitializingBean, DisposableBean { @PostConstruct pub原创 2020-09-03 13:34:31 · 174 阅读 · 0 评论 -
【随记】Springboot集成Redis配置(单机,集群)
文章目录1.配置文件单机配置集群配置配置说明衍生说明2.版本说明3.pom依赖1.配置文件单机配置spring.redis.host=127.0.0.1spring.redis.port=6379spring.redis.password=spring.redis.lettuce.pool.max-active=8spring.redis.lettuce.pool.max-wait=-1spring.redis.lettuce.pool.max-idle=8spring.redis.let原创 2020-08-18 14:11:39 · 580 阅读 · 0 评论 -
【DEMO】SpringBoot整合NSQ
仅仅是一个最简单的DEMO实现pom引用<!-- NSQ - JavaNSQClient --><dependency> <groupId>com.github.brainlag</groupId> <artifactId>nsq-client</artifactId> <versio...原创 2019-04-18 16:43:19 · 1900 阅读 · 0 评论 -
【坑】【SpringBoot】指定服务项目名
使用不同SpringBoot版本,指定访问项目路径的项目名,使用的配置也不一样 有网友指出 SpringBoot版本 配置 1.x server.context-path=/demo 2.x server.servlet.context-path=/demo以下为本地测试可行代码pom.xml中使用SpringBoot版本&...原创 2018-06-07 17:37:08 · 25999 阅读 · 1 评论