Announcement Announcement Module
Collapse
No announcement yet.
How to use property loader in java based webapp initilizer with servlet 3.0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use property loader in java based webapp initilizer with servlet 3.0

    I am trying to initialize my DispatcherServlet using AbstractAnnotationConfigDispatcherServletInitializ er class using spring 3.2. For adding servlet 3.0 based multipart/form-data request, I have also overridden the method customizeRegistration for setting multipart config element as this.

    Code:
     
     
      @Override
      protected void customizeRegistration(ServletRegistration.Dynamic registration) {
            super.customizeRegistration(registration);
    
            registration.setMultipartConfig(new MultipartConfigElement(fileTempLocation,maxFileSize,maxFileSize,fileSizeThreshold));
        }
    I have a root application context class where property loader is configured. However, I am not able to use the value from property file in customizeRegistration method. Propertyloader is getting initialized after the customizeRegistration.

    Is there a way to force the loading of my configuration class? Have tried to move propertyloader bean in the webAppInitializer class but didnot work.

    I don't want to either hardcode the values for maxFIleSize etc.. Is there a way I can do this using java based configuration?

  • #2
    In the WebApplicationInitializers you don't have access to those beans, they actually don't even have to exist right now. You are still bootstrapping and configuring your application, after that is done the container kicks of all ServletContextListeners and Servlets.

    The only thing that might work is using context-params from the servlet context and override them when you deploy the application in different environments.

    Comment


    • #3
      Thanks Marten for the response. Is there a better way to set up MultipartConfig element such that I will have the flexibility to use properties file.

      Comment

      Working...
      X