當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
【SpringBoot零基础案例08】【IEDA 2021.1】SpringBoot获取核心配置文件application.properties中的自定义配置
生活随笔
收集整理的這篇文章主要介紹了
【SpringBoot零基础案例08】【IEDA 2021.1】SpringBoot获取核心配置文件application.properties中的自定义配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
IndexController代碼:
package com.zx.springboot.web;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;import java.util.HashMap; import java.util.Map;/*** @author zx* @project_name springboot-projects* @create 2021-06-18 9:39*/ @Controller public class IndexController {@Value("${student.age}")private int age;@Value("${student.name}")private String studentname;@RequestMapping("/say")@ResponseBodypublic Map<String, Object> mapValue(Object StringBoot) {StringBoot = "stringBoot!!!";Map<String, Object> retMap = new HashMap<>();retMap.put("Hello", StringBoot);return retMap;}@RequestMapping("/stu")@ResponseBodypublic String student(){return "學生姓名:" + studentname + ":" + "學生年齡:" + age;}}運行結果:
總結
以上是生活随笔為你收集整理的【SpringBoot零基础案例08】【IEDA 2021.1】SpringBoot获取核心配置文件application.properties中的自定义配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 端口号被占用时,查找占用该端口号的进程并
- 下一篇: 【SpringBoot零基础案例09】【