Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add multiple properties file in spring configuration

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.08k
    Comment on it

    Here we have configured the spring mvc configuration. In @ComponentScan we can give the path where we have our components(like controller, model, dao etc).

    For adding the single properties file we use: @PropertySource("classpath:application.properties")

    and for multiple files we use: @PropertySources({ @PropertySource("classpath:application.properties"), @PropertySource("classpath:mail.properties") })

    @Configuration
    @EnableWebMvc
    @EnableTransactionManagement
    @ComponentScan(basePackages = "com.data.*")
    @PropertySources({
        @PropertySource("classpath:application.properties"),
        @PropertySource("classpath:mail.properties")
    })
    public class CustomConfiguration extends WebMvcConfigurerAdapter {
         //other configuration details like view resolver, data source, hibernate setting etc.
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: