I want to define thread count for my fixed thread pool in my spring application. Where should I do that? I am confused between yaml and application.properties files.
CodePudding user response:
You should define the thread count for your fixed thread pool in the application.properties file
. This is the default configuration file for Spring applications, and it is the recommended place to store configuration settings. You can specify the number of threads for your fixed thread pool with the property spring.task.execution.pool.core-size
.
For example, if you wanted to define a fixed thread pool with 10 threads, you would add the following to your application.properties file: spring.task.execution.pool.core-size=10
As per Srping boot doc :
YAML files cannot be loaded by using the @PropertySource or @TestPropertySource annotations. So, in the case that you need to load values that way, you need to use a properties file.
Refer to this SO1 and SO2 to know the difference between yaml and application.properties files.