Spring Tutorial 22 - Using MessageSource To Get Text From Property Files

preview_player
Показать описание
In this tutorial, we'll use the MessageSource interface to retrieve messages out of property files.
Рекомендации по теме
Комментарии
Автор

Teaching is a sacred job and people like you make it even sacred.Thank you for your awesome tutorials .Keep up good work.

jagansirigiri
Автор

awesome explanation thanks for the efforts you made for clean understanding of each concepts in spring

girishkumar
Автор

This works perfectly:

It's not mandatory to have list always.

<bean name="messageSource"
<property name="basename" value="file:src/q" />
<property value="true" />
</bean>

sagarish
Автор

Java Brains I am getting null pointer exception when i tried to print the message in Circle class (Drawing Circle!) with same exact code in the video. Then, i removed @Autowired annotation and implemented MessageSourceAware in Circle class, implemented setMessageSource method to set this.messageSource to messageSource and it works like a charm. Just to let you know, I'm using spring 4.0.6 JARs in my eclipse project. 

Finally, Kudos to you for helping us learn Spring Basics! Job well done.

apt
Автор

this is awesome tutorial, just completed spring core now moving to AOP.

rtech
Автор

Hi Kaushik, Thanks for such a great tutorial.

writesach
Автор

This whole tutorial series is Awesome!

GurnBograt
Автор

But I like that part of this videos that he repeats what he does.
English is not my first language so it helps alot to hear it again in a slightly different way ;)

SoeaOu
Автор

It was I who called Koushik at 15:44
_(You can hear his mobile vibrate)_

parthsalat
Автор

Excellent tutorial :)
P.S. Repeating some of the issues is a good convention :) It allow me to solidify gained knowledge.

TheUnixHead
Автор

u might have figured out the problem by now, but for the benefit of anyone facing the same problem... the property 'name' must be 'basenames' when u r using a "list", as in this tutorial. But if you are using the value attribute inside the property-tag to define a filename, the 'name' of the property must be 'basename'. Hope it helps.

MandeepSingh-bvzw
Автор

Thanks for your kind effort for teaching us!

reloaderify
Автор

for every one have problem of print the default message the problems is :
1- be sure from the name of your properties in the value of property "basenames"
2- be sure from your file mymessages.properties it exisit in the same path of your xml file "under src"
i hope you ll solve your problem soon

hedjerciyakoub
Автор

I must say its a nice collection of videos that you have made very informative and a must see for Spring beginners but I must also say that you are repeating the same things over and over again like once when you have defined what you will do and after writing the code you go and repeat what you have done which for me was really really boring. But whatever, these tutorials are really nice and more than worth a look. Thanks for the tutorial....THUMBS

tubeyouish
Автор

Nice Explanation!
I've one query here, in case if we've more than 1 properties files, then can we can add that file names in the "value" tag of the same "list" tag where we've file name "mymessages" ?

sandeepgabhale
Автор

Dear Sir, Your explanation is simply outstanding,
encouraging
but u have only one tone...
It could be more better if u could add some toning differentiation during explanation..
Overall I like your methodology compare to other Programming lectures ...

abdulsattarshaikh
Автор

Even I faced the same problem. I had set the 'bean id' to some custom name, just to see if it works. It didn't. So I changed it to "messageSource" and it still didn't work. All I had to do was to "Clean" the project.

Are you sure your bean id = "messageSource" ? If its not, change it to "messageSource". I learnt the hard way that it needs to be exactly this and not anything else.

My config changes were not picked up by eclipse, so I had to clean the project and then it just worked like charm.

MandeepSingh-bvzw
Автор

it could be a weird question but I am still a beginner with Spring:
what is the sense of using the parameters array in the getMessage method?
In particular, looking at  this.messageSource.getMessage("circle.points", new Object[] {this.getCenter(), this.getRadius()}, "Default greeting", null) we are passing parameters that we already own! Why passing parameters to the property file (mymessage.properties) and get them backwards again? Is there a more useful case of use? Thanks! 

floggerN
Автор

awesome learning here. thankx java brains. same code i have tried but its giving me null pointer exception. then in the center class i have implemented MessageSourceAware, its work fine i dont know the reason why??

jinendrakumarjain
Автор

Hi Kaushik,

Thanks for your tutorials, However I am getting null pointer exception when injecting MessageSource in my class using @Autowired annotation. Could you please help?

Choudhary_Chacha
welcome to shbcf.ru