Grails message.properties changes not taking effect in deployed application

 ̄綄美尐妖づ 提交于 2019-12-10 11:01:38

问题


I have a really annoying problem with a deployed Grails application on tomcat 7

I created a tool in my website that basically allows the site admin to edit message.properties files so that he can change the messages for a certain language as he desire.

All the changes are saved successfully to the file he edited.

In development, while running the website from STS (Soring Source Tools Suite; somethng like eclips) I just refresh the website in the browser and I see the changes instantly, all the changes that made to the message.properties file for the selected language is taking effect correctly.

But in the deployed application (same code same config no errors) the admin do the same thing, edit the resources in the same way as before, the message.properties file is saved with the new values correctly, but, I dont see the changes in the browser, unless I restarted tomcat, or after number of hours!

I've disabled the tomcat 7 caching, and I still face the same problem. I've spent more than 4 days googling, but all the results are not related to my problem, and most of them are related to hibernate caching.

So, my question simply is as follows:

I want to go to a message.properties file in my deployed grails application, lets say message_en.properties, change lets say default.welcome.message=Welcome to default.welcome.message=Hello, World! And then open any browser, and see Hello, World! instead of Welcome

Thanks in advance for any help =')


回答1:


As they say, some big questions have a very simple answer! Depending on a post I found, in my resources editor tool, I added this code in my action with other few changes in the bootstarp (see link at the end of the answer):

def messageSource
def saveMessageResources={
    .
    .
    .
    //my action logic
    .
    .
    .    
    messageSource.clearCache()
}

and it worked :)

References: http://jira.grails.org/browse/GPAPPENGINE-44




回答2:


Deployed application will not pick up changes until you restart it. Changes are reloaded on-thy-fly only in development mode for your convenience. It is called "hot-deployment" because only parts that are changed (messages.properties in your case) are applied.

If you want to edit messages in deployed application you can apply alternative solution - localisation plugin that keeps your messages in database.



来源:https://stackoverflow.com/questions/12671192/grails-message-properties-changes-not-taking-effect-in-deployed-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!