3.SpringBoot-properties配置

一.自动配置内容

更多请查看:http://docs.spring.io/spring-boot/docs/1.2.3.RELEASE/reference/html/common-application-properties.html

1.mysql数据库配置

如果你设置spring.datasource.driverClassName=com.mysql.jdbc.Driver,然后这个类就会被自动加载。

DataSource配置通过外部配置文件的spring.datasource.*属性控制。

实例:

spring.datasource.url=jdbc:mysql://localhost/test

spring.datasource.username=dbuser

spring.datasource.password=dbpass

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

其他可选的配置可以查看DataSourceProperties。

2.redis配置

实例:

spring.redis.port=6379

spring.redis.database=0


spring.redis.host=

spring.redis.password=

spring.redis.timeout=2000

3.设置生效的profie(多环境配置)

spring.profiles.active=production

server.port=80

4.设置随机数

#随机字符串com.bluecoffee.random.str=${random.value}

#随机intcom.bluecoffee.random.number=${random.int}

#随机longcom.bluecoffee.random.bigNumber=${random.long}

#10以内的随机数com.bluecoffee.random.test1=${random.int(10)}

5.属性注入

com.bluecoffee.space.title=‘题目’


@Value("${com.bluecoffee.space.title}") privateStringblogTitle;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值