SpringBoot可以识别两种格式的配置文件,分别是yml文件与properties文件,可以将application.properties文件换成application.yml

application.properties默认放在:src/main/resource目录下,SpringBoot会自动加载

比较常用的配置

server.port=xxxx #端口

系统属性/变量

spring.profiles.active=xxx

该系统变量可以指明要使用的配置文件,一般应用于多环境配置分离

如:

  spring.profiles.active=dev

  在启动时会加载application-dev.properties配置文件,和application.properties在同一目录下

mysql基本配置

引入spring-boot-starter-jdbc

spring.datasource.url=jdbc:mysql://localhost:3306/dataname?serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

MyBatis配置

引入mybatis-spring-boot-starter

mybatis.config-location=classpath:mybatis/mybatis-config.xml  #放在resources/mybatis/mybatis-config.xml中
mybatis.mapper-locations= classpath:mybatis/mapper/*.xml
mybatis.type-aliases-package=com.form.model #类型转换器包,多个逗号隔开

redis基本配置

引入spring-boot-starter-data-redis

spring.redis.host=127.0.0.1
spring.redis.port=
spring.redis.password=
spring.redis.timeout=

banner配置

项目启动时打印的一堆符号

banner.location=xxx.txt  #可以自定义输出信息的位置
banner.charset=utf- #指定编码格式
spring.main.banner-mode=console/off #banner图开启或者打印模式

字符画生成的网站

http://www.network-science.de/ascii/
http://patorjk.com/software/taag/

application.properties配置文件的更多相关文章

  1. Spring Boot加载application.properties配置文件顺序规则

    SpringApplication会从以下路径加载所有的application.properties文件: 1.file:./config/(当前目录下的config文件夹) 2.file:./(当前 ...

  2. eclipse创建spring boot项目加载不到application.properties配置文件

    在配置文件application.properties中修改了端口号,但重启服务后发现端口号并没有跟着改变,发现是项目启动时没有加载application.properties文件导致 解决:项目-& ...

  3. Java 读取application.properties配置文件中配置

    实际开发中若需要读取配置文件application.properties中的配置,代码如下.例:读取配置文件中name属性配置值: 代码如下: import org.springframework.c ...

  4. springboot使用外部application.properties配置文件

    一.背景介绍 springboot默认的application.properties文件只能在项目内部,如果打成docker镜像后配置文件也打进去了,这样每次需要改动配置(比如数据库的连接信息)就需要 ...

  5. SpringBoot 项目不加载 application.properties 配置文件

    起因:新安装的idea第一次运行springboot项目报url错误(Failed to configure a DataSource: 'url' attribute is not specifie ...

  6. eclips环境下开发spring boot项目,application.properties配置文件下中文乱码解决方案

    如以上,application.properties文件下中文乱码.发生乱码一般都是由于编码格式不一样导致的. 打开Window-Preferences-General-content Types-T ...

  7. spring boot项目,application.properties配置文件下中文乱码解决方案

    转自:https://blog.csdn.net/qq_40408534/article/details/79831807 如以上,application.properties文件下中文乱码.发生乱码 ...

  8. spring boot入门笔记 (二) - application.properties配置文件

    项目最重要的一个东西,用来定义整个项目的一些东西(端口.访问项目的名称.数据源.日志.集成mybatis等框架.静态资源目录.thymeleaf.热部署等),很重要很重要的. #整个项目的端口号,默认 ...

  9. springboot项目logback.xml或者logback-spring.xml中读取不到application.yml或application.properties配置文件中的配置解决办法

    在springboot项目中我们可能想要实现不同环境的日志项目配置不同,比如我想让不同环境的日志路径不同. 这时候我们很容易想: 1.到将日志路径配置在springboot的:application- ...

随机推荐

  1. BZOJ1290 : [Ctsc2009]序列变换

    设$f[i][j]$表示$a[i]$改成$j$时的最小总代价. 若$a[i]<A(i-1)+1$,则不妨将其强行改成$A(i-1)+1$,如此处理之后$\min(f[n][1..Q])$就是答案 ...

  2. CallContext,ThreadStatic,AsyncLocal<T>,ThreadLocal<T>,学习笔记

    1.CallContext 在当前调用上下文的线程数据槽里存储对象 2.ThreadStatic 是一个特性 3.AsyncLocal<T> 是一个类型,该字段应当为static,保证单例 ...

  3. JS RegExp类型

    用来定义正则表达式的类型, 1. 通常情况下,我们可以直接用字面量形式来定义正则表达式,格式如下: var expression = /pattern/flags pattern为正则表达式 flag ...

  4. innerHTML innerText与outerHTML间的区别

    innerHTML与innerText及outerHTML间的区别最容易使初学者搞混淆,为了更好的使读者区分开.下面我就通过一个demo来解释: 代码: <!DOCTYPE html>&l ...

  5. 单向LSTM笔记, LSTM做minist数据集分类

    单向LSTM笔记, LSTM做minist数据集分类 先介绍下torch.nn.LSTM()这个API 1.input_size: 每一个时步(time_step)输入到lstm单元的维度.(实际输入 ...

  6. sencha cmd 创建项目

    一.软件支持 1.下载并解压Sencha Touch(浏览器支持Chrome.Safari.Internet Explorer 10或11.) 2.Sencha Cmd(Sencha Touch 2. ...

  7. poj3617 Best Cow Line(贪心,字典序问题)

    https://vjudge.net/problem/POJ-3617 这类字符串处理字典序问题经常用到贪心, 每决定输出一个字符之前,都要前后i++,j--逐个比大小,直至比出为止. #includ ...

  8. [CentOS7]安装tomcat并开启自启动

    安装jdk 1.CentOS 6.X 和 7.X 自带有OpenJDK runtime environment (openjdk).它是一个在linux上实现开源的Java 平台. yum searc ...

  9. Cocos Creator脚本开发事例

    HelloWorld.js window.Global = { gint: 168, }; cc.Class({ extends: cc.Component, properties: { label: ...

  10. Docker搭建带有访问认证的私有仓库

    2017年06月10日 17:30:26 阅读数:2581 以下步骤均为本人亲自踩坑,历经数次失败,最终搭建成功 一.环境信息: 操作系统:CentOS 7 Docker版本:1.12.5 (更高版本 ...