springboot入门

╄→尐↘猪︶ㄣ 提交于 2021-02-16 05:36:08

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

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!