02. Spring boot 之 profile 配置
发表于
分类于
Spring Boot
设置激活 Spring Profiles
SPRING Environment 为此提供了一个 API,但是您通常会设置一个 System 属性(spring.profiles.active) 或者一个 OS 环境变量(SPRING_PROFILES_ACTIVE)。此外,您可以使用 -D 参数启动应用程序(记住将其放在 main 类或 jar 归档之前) ,如下所示:
1 | java -jar -Dspring.profiles.active=production demo-0.0.1-SNAPSHOT.jar |
或者
1 | java -jar demo-0.0.1-SNAPSHOT.jar --spring.profiles.active=production |
在 Spring Boot 中,您还可以在 application.properties 中设置 active profile ,如下面的示例所示:
可以是一个
1 | spring.profiles.active=production |
也可以是多个
1 | spring.profiles.active=dev,hsqldb |
或者使用 application.yml 形式
1 | spring: |
01. Spring Boot 简介
发表于
分类于
Spring Boot
Spring Boot 介绍
Spring Boot 2.3.12.RELEASE API 参考
Spring Boot 参考文档
https://docs.spring.io/spring-boot/docs/2.3.12.RELEASE/reference/html/
03. 装配 Bean
10. Spring Shell
有的时候创建命令行应用程序可能很有用,例如与项目的 REST API 交互,或者使用本地文件内容。
Spring Shell,可以和 SpringBoot 一起制作一款命令行工具。可轻松构建一个功能完整的 Shell (又名命令行)应用程序。
特性
Spring Shell 的特性包括
- 一个简单的、注释驱动的编程模型,用于提供自定义命令
- 使用 Spring Boot 自动配置功能作为命令插件策略的基础
- 选项卡完成、彩色化和脚本执行
- 自定义命令提示符、 shell 历史文件名、结果处理和错误
- 基于领域特定条件的命令动态启用
- 与 bean 验证 API 的集成
- 已经内置的命令,如清晰的屏幕,华丽的帮助,退出
- ASCII 艺术表格,具有格式化、对齐、花哨的边框等。
