















package com.imooc.myspringboot_inttell.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class MyController {
@Value("${mall.config.name}")
private String name;
@Value("${mall.config.description}")
private String description;
@Value("${mall.config.hot-sales}")
private Integer hotSales;
@Value("${mall.config.show-advert}")
private Boolean showAdvert;
@RequestMapping("/out")
@ResponseBody
public String out(){
return "success";
}
@RequestMapping("/info")
@ResponseBody
public String info(){
return String.format("name:%s,description:%s,hot-sales:%s,show-advert:%s",
name,description,hotSales,showAdvert);
}
}
application.yml
spring: profiles: active: prd
application-dev.yml
debug: true
#logging.level.root
#logging.file
logging:
level:
root: info
file: e:/myspringboot.log
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/test
username: root
password:
mall:
config:
name: 爱美商城
description: 这是一家化妆品特卖网站
hot-sales: 20
show-advert: true
application-prd.yml
debug: false
#logging.level.root
#logging.file
logging:
level:
root: info
file: /local/user/app-prd.log
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://155.32.55.88:3307/prd
username: root
password: 123456
mall:
config:
name: 优美商城
description: 这是一家化妆品特卖网站
hot-sales: 20
show-advert: true
server:
port: 80
来源:oschina
链接:https://my.oschina.net/u/3872916/blog/1843392