Ankit
Ankit

Reputation: 433

Bean dynamic values in Spring MVC

I had made project on Spring MVC few months back.

I am facing a problem that values on the bean are changing from time to time.

After changing the values, I needs to restart the Apache Tomcat.

How can I implement the change in values without restarting Apache Tomcat.

Kindly find following bean declaration in spring-servlet.xml file

<bean id="beanmessage" class="examresults.bean.MessageClass" lazy-init="true">

    <property name="imagelocation" value="/home/mmi/Pictures/examresultspics"/> 

    <property name="boardslist">
        <list>
            <value>Bihar Board</value>
            <value>CBSE Board</value>
            <value>UP Board</value>
            <value>Jharkhand Board</value>
            <value>Uttarakhand Board</value>
            <value>Punjab Board</value>
            <value>MP Board</value>
            <value>Chhattisgarh Board</value>
        </list>
    </property>

    <property name="departmentlist">
        <list>
            <value>10th</value>
            <value>12th</value>
            <value>AIEEE</value>
            <value>AIPMT</value>
        </list>
    </property>

</bean>

I am not a experienced person in Spring domain.

Kindly provide some links so that I can understand these concepts.

Upvotes: 0

Views: 134

Answers (1)

JB Nizet
JB Nizet

Reputation: 692231

Instead of reading the values from a static Spring configuration file, read them at runtime from the database. When you want to change the values, you change them in the database, and the code reads the new values immediately without having to redeploy the application.

You should only use configuration files for purely static values, that are chosen at deployment time and never change afterwards.

Upvotes: 3

Related Questions