Can we change the location of springBeanConfiguration file in spring mvc?









up vote
0
down vote

favorite
1












I have developed a Spring MVC web application. In this application I have two containers and the location of the spring bean configuration file is:



/WEB-INF/dispatcher-servlet.xml 


I have changed the name of the spring bean cfg file but I also want to change the location to:



/com/nt/cfg/applicationContext.xml 


However, Spring is not recognizing any location other than /WEB-INF/










share|improve this question



























    up vote
    0
    down vote

    favorite
    1












    I have developed a Spring MVC web application. In this application I have two containers and the location of the spring bean configuration file is:



    /WEB-INF/dispatcher-servlet.xml 


    I have changed the name of the spring bean cfg file but I also want to change the location to:



    /com/nt/cfg/applicationContext.xml 


    However, Spring is not recognizing any location other than /WEB-INF/










    share|improve this question

























      up vote
      0
      down vote

      favorite
      1









      up vote
      0
      down vote

      favorite
      1






      1





      I have developed a Spring MVC web application. In this application I have two containers and the location of the spring bean configuration file is:



      /WEB-INF/dispatcher-servlet.xml 


      I have changed the name of the spring bean cfg file but I also want to change the location to:



      /com/nt/cfg/applicationContext.xml 


      However, Spring is not recognizing any location other than /WEB-INF/










      share|improve this question















      I have developed a Spring MVC web application. In this application I have two containers and the location of the spring bean configuration file is:



      /WEB-INF/dispatcher-servlet.xml 


      I have changed the name of the spring bean cfg file but I also want to change the location to:



      /com/nt/cfg/applicationContext.xml 


      However, Spring is not recognizing any location other than /WEB-INF/







      java spring-mvc web-inf deployment-descriptor






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 17:15









      Graham

      3,461123558




      3,461123558










      asked Nov 9 at 15:24









      vinay pratap singh

      92




      92






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          You just need to declare de route when you create the ClassPathXmlApplicationContext:



          ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");


          The default location is the resources folder.



          Hope this help you.






          share|improve this answer




















          • no zaloan i am not worry about to create container explicitly i wan to change the location deployment-descriptor of spring mvc DispatcherServlet supply WebApplicationContext container that is by default search spring bean configuration file in /WEB-INF/ directory
            – vinay pratap singh
            Nov 9 at 16:35

















          up vote
          0
          down vote













          The answer is YES, you can change the name and location of the configuration file but you have to make spring aware of the new name and location.



          ApplicationContext context = new ClassPathXmlApplicationContext("context.xml"); 


          It will load the context from context.xml file (context.xml should be present in classpath).

          You can create new Applicationcontext by passing desired XML file as parameter to constructor.



          So after changing name and location of the file you have to register here for spring reference so that spring can find the configuration file.






          share|improve this answer




















          • no i am not interested to create explicitly create container by user in spring dispatcher servlet already provide predefined ioc container WebApplicationContext with fixed location /WEB-INF/dispatcher-servlet.xml but i want to change the location of spring bean cfg file in eclipse where our java classes are reside
            – vinay pratap singh
            Nov 11 at 7:18










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228581%2fcan-we-change-the-location-of-springbeanconfiguration-file-in-spring-mvc%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          You just need to declare de route when you create the ClassPathXmlApplicationContext:



          ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");


          The default location is the resources folder.



          Hope this help you.






          share|improve this answer




















          • no zaloan i am not worry about to create container explicitly i wan to change the location deployment-descriptor of spring mvc DispatcherServlet supply WebApplicationContext container that is by default search spring bean configuration file in /WEB-INF/ directory
            – vinay pratap singh
            Nov 9 at 16:35














          up vote
          0
          down vote













          You just need to declare de route when you create the ClassPathXmlApplicationContext:



          ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");


          The default location is the resources folder.



          Hope this help you.






          share|improve this answer




















          • no zaloan i am not worry about to create container explicitly i wan to change the location deployment-descriptor of spring mvc DispatcherServlet supply WebApplicationContext container that is by default search spring bean configuration file in /WEB-INF/ directory
            – vinay pratap singh
            Nov 9 at 16:35












          up vote
          0
          down vote










          up vote
          0
          down vote









          You just need to declare de route when you create the ClassPathXmlApplicationContext:



          ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");


          The default location is the resources folder.



          Hope this help you.






          share|improve this answer












          You just need to declare de route when you create the ClassPathXmlApplicationContext:



          ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");


          The default location is the resources folder.



          Hope this help you.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 9 at 15:28









          gonzaloan

          1067




          1067











          • no zaloan i am not worry about to create container explicitly i wan to change the location deployment-descriptor of spring mvc DispatcherServlet supply WebApplicationContext container that is by default search spring bean configuration file in /WEB-INF/ directory
            – vinay pratap singh
            Nov 9 at 16:35
















          • no zaloan i am not worry about to create container explicitly i wan to change the location deployment-descriptor of spring mvc DispatcherServlet supply WebApplicationContext container that is by default search spring bean configuration file in /WEB-INF/ directory
            – vinay pratap singh
            Nov 9 at 16:35















          no zaloan i am not worry about to create container explicitly i wan to change the location deployment-descriptor of spring mvc DispatcherServlet supply WebApplicationContext container that is by default search spring bean configuration file in /WEB-INF/ directory
          – vinay pratap singh
          Nov 9 at 16:35




          no zaloan i am not worry about to create container explicitly i wan to change the location deployment-descriptor of spring mvc DispatcherServlet supply WebApplicationContext container that is by default search spring bean configuration file in /WEB-INF/ directory
          – vinay pratap singh
          Nov 9 at 16:35












          up vote
          0
          down vote













          The answer is YES, you can change the name and location of the configuration file but you have to make spring aware of the new name and location.



          ApplicationContext context = new ClassPathXmlApplicationContext("context.xml"); 


          It will load the context from context.xml file (context.xml should be present in classpath).

          You can create new Applicationcontext by passing desired XML file as parameter to constructor.



          So after changing name and location of the file you have to register here for spring reference so that spring can find the configuration file.






          share|improve this answer




















          • no i am not interested to create explicitly create container by user in spring dispatcher servlet already provide predefined ioc container WebApplicationContext with fixed location /WEB-INF/dispatcher-servlet.xml but i want to change the location of spring bean cfg file in eclipse where our java classes are reside
            – vinay pratap singh
            Nov 11 at 7:18














          up vote
          0
          down vote













          The answer is YES, you can change the name and location of the configuration file but you have to make spring aware of the new name and location.



          ApplicationContext context = new ClassPathXmlApplicationContext("context.xml"); 


          It will load the context from context.xml file (context.xml should be present in classpath).

          You can create new Applicationcontext by passing desired XML file as parameter to constructor.



          So after changing name and location of the file you have to register here for spring reference so that spring can find the configuration file.






          share|improve this answer




















          • no i am not interested to create explicitly create container by user in spring dispatcher servlet already provide predefined ioc container WebApplicationContext with fixed location /WEB-INF/dispatcher-servlet.xml but i want to change the location of spring bean cfg file in eclipse where our java classes are reside
            – vinay pratap singh
            Nov 11 at 7:18












          up vote
          0
          down vote










          up vote
          0
          down vote









          The answer is YES, you can change the name and location of the configuration file but you have to make spring aware of the new name and location.



          ApplicationContext context = new ClassPathXmlApplicationContext("context.xml"); 


          It will load the context from context.xml file (context.xml should be present in classpath).

          You can create new Applicationcontext by passing desired XML file as parameter to constructor.



          So after changing name and location of the file you have to register here for spring reference so that spring can find the configuration file.






          share|improve this answer












          The answer is YES, you can change the name and location of the configuration file but you have to make spring aware of the new name and location.



          ApplicationContext context = new ClassPathXmlApplicationContext("context.xml"); 


          It will load the context from context.xml file (context.xml should be present in classpath).

          You can create new Applicationcontext by passing desired XML file as parameter to constructor.



          So after changing name and location of the file you have to register here for spring reference so that spring can find the configuration file.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 10 at 5:17









          Alien

          4,28521023




          4,28521023











          • no i am not interested to create explicitly create container by user in spring dispatcher servlet already provide predefined ioc container WebApplicationContext with fixed location /WEB-INF/dispatcher-servlet.xml but i want to change the location of spring bean cfg file in eclipse where our java classes are reside
            – vinay pratap singh
            Nov 11 at 7:18
















          • no i am not interested to create explicitly create container by user in spring dispatcher servlet already provide predefined ioc container WebApplicationContext with fixed location /WEB-INF/dispatcher-servlet.xml but i want to change the location of spring bean cfg file in eclipse where our java classes are reside
            – vinay pratap singh
            Nov 11 at 7:18















          no i am not interested to create explicitly create container by user in spring dispatcher servlet already provide predefined ioc container WebApplicationContext with fixed location /WEB-INF/dispatcher-servlet.xml but i want to change the location of spring bean cfg file in eclipse where our java classes are reside
          – vinay pratap singh
          Nov 11 at 7:18




          no i am not interested to create explicitly create container by user in spring dispatcher servlet already provide predefined ioc container WebApplicationContext with fixed location /WEB-INF/dispatcher-servlet.xml but i want to change the location of spring bean cfg file in eclipse where our java classes are reside
          – vinay pratap singh
          Nov 11 at 7:18

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228581%2fcan-we-change-the-location-of-springbeanconfiguration-file-in-spring-mvc%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Darth Vader #20

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Ondo