当前位置:网站首页>23.6 23.7 web environment web environment variable reading
23.6 23.7 web environment web environment variable reading
2022-07-26 08:29:00 【csg103】
One SpringApplication Will try to create the correct type ApplicationContext . By default, it will depend on whether you are developing a web Application and use AnnotationConfigApplicationContext or AnnotationConfigEmbeddedWebApplicationContext . Decide to use web The algorithm of environment is actually very simple ( Based on the existence of several classes ), To override this default mechanism, use setWebEnvironment(boolean webEnvironment) .
in addition , It can also be taken by calling setApplicationContextClass(…) What is used ApplicationContext Type to fully control . Usually in JUnit Use in test SpringApplication Called when setWebEnvironment(false) .
Add project parameters args1 234

New registration bean
@Component public class MyBean { @Autowired public MyBean(ApplicationArguments args){ boolean debug = args.containsOption("debug"); List<String> files = args.getNonOptionArgs(); // if run with "--debug logfile.txt" debug=true, files=["logfile.txt"] } }
debug Run in mode

边栏推荐
猜你喜欢

【时间复杂度空间复杂度】

NLP (natural language processing) natural language processing learning

Kotlin variables and constants

Basic configuration of BGP

matplotlib学习笔记

C # get the information of the selected file

2022-7-7 personal qualifying 4 competition experience

Apple's tough new rule: third-party payment also requires a percentage, and developers lose a lot!

Write common API tools swagger and redoc

Prefix infix suffix expression (written conversion)
随机推荐
Burp Suite - Chapter 1 burp suite installation and environment configuration
Problems caused by slivereappbar
Take out brother is the biggest support in this society
2022-7-9 personal qualifying 6 competition experience
2022-024ARTS:最长有效括号
A little awesome, 130000 a month+
Uninstallation of dual systems
flink oracle cdc 读取数据一直为null,有大佬知道么
es6中函数默认参数、箭头函数、剩余参数-讲解
Kotlin中room数据库的使用
QT uses QSS to make a beautiful login interface (hand-in-hand teaching)
Kotlin data type
vscode国内的镜像服务器加速
苹果强硬新规:用第三方支付也要抽成,开发者亏大了!
shell编程
Lesson 3: gcc compiler
NLP (natural language processing) natural language processing learning
Nodejs2day(nodejs的模块化,npm下载包,模块加载机制)
SPSS uses kmeans, two-stage clustering and RFM model to study the behavior law data of borrowers and lenders in P2P network finance
Dev gridcontrol 捕获按键事件