I run spring boot application with a single argument - filename. The file contains some properties I need in runtime. When the application starts it checks if args.length==1
But I need this file (properties) in a single point - @Component
annotated bean.
Is it a way to get an access to the file's content from it?
In Spring, there is a bean called ApplicationArguments that provides access to the arguments used to run an application.
@Component
public MyComponent {
@Autowired
private ApplicationArguments applicationArguments;
public void method() {
List<String> filenameArgs = applicationArguments.getOptionValues("filename")
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.